[longomatch] Add unit tests for drawables



commit 54b3990b98538f9102e303473986646d42fd75c6
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Mar 4 16:23:37 2015 +0100

    Add unit tests for drawables

 LongoMatch.Core/Store/Drawables/MultiPoints.cs |    8 ++++----
 LongoMatch.Core/Store/Point.cs                 |    8 --------
 Tests/Core/Drawables/TestMultipoints.cs        |    8 ++++----
 Tests/Core/TestPoint.cs                        |   12 ++++++++++++
 Tests/Makefile.am                              |   11 ++++++++++-
 Tests/Tests.csproj                             |    9 +++++++++
 6 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Drawables/MultiPoints.cs b/LongoMatch.Core/Store/Drawables/MultiPoints.cs
index 03fe5db..aa93978 100644
--- a/LongoMatch.Core/Store/Drawables/MultiPoints.cs
+++ b/LongoMatch.Core/Store/Drawables/MultiPoints.cs
@@ -81,10 +81,10 @@ namespace LongoMatch.Core.Store.Drawables
                        xmax = px[px.Count-1].X;
                        ymin = py[0].Y;
                        ymax = py[py.Count-1].Y; 
-                       BottomLeft = new Point (xmin, ymin);
-                       TopLeft = new Point (xmin, ymax);
-                       TopRight = new Point (xmax, ymax);
-                       BottomRight = new Point (xmax, ymin);
+                       TopLeft = new Point (xmin, ymin);
+                       TopRight = new Point (xmax, ymin);
+                       BottomLeft = new Point (xmin, ymax);
+                       BottomRight = new Point (xmax, ymax);
                } 
        }
 }
diff --git a/LongoMatch.Core/Store/Point.cs b/LongoMatch.Core/Store/Point.cs
index 4ffbcf5..c9ff100 100644
--- a/LongoMatch.Core/Store/Point.cs
+++ b/LongoMatch.Core/Store/Point.cs
@@ -74,14 +74,6 @@ namespace LongoMatch.Core.Common
                        return (X.ToString() + "-" + Y.ToString()).GetHashCode();
                }
                
-               public static bool operator < (Point p1, Point p2) {
-                       return p1.X < p2.X && p1.Y < p2.Y;
-               }
-               
-               public static bool operator > (Point p1, Point p2) {
-                       return p1.X > p2.X && p1.Y > p2.Y;
-               }
-               
                public static Point operator + (Point p1, Point p2) {
                        return new Point (p1.X + p2.X, p1.Y + p2.Y);
                }
diff --git a/Tests/Core/Drawables/TestMultipoints.cs b/Tests/Core/Drawables/TestMultipoints.cs
index c3b43e6..fe2a33b 100644
--- a/Tests/Core/Drawables/TestMultipoints.cs
+++ b/Tests/Core/Drawables/TestMultipoints.cs
@@ -68,10 +68,10 @@ namespace Tests.Core.Drawables
                        ymax = 8;
                        
                        MultiPoints m = new MultiPoints (l);
-                       Assert.AreEqual (new Point (xmin, ymax), m.TopLeft);
-                       Assert.AreEqual (new Point (xmax, ymax), m.TopRight);
-                       Assert.AreEqual (new Point (xmax, ymin), m.BottomRight);
-                       Assert.AreEqual (new Point (xmin, ymin), m.BottomLeft);
+                       Assert.AreEqual (new Point (xmin, ymin), m.TopLeft);
+                       Assert.AreEqual (new Point (xmax, ymin), m.TopRight);
+                       Assert.AreEqual (new Point (xmax, ymax), m.BottomRight);
+                       Assert.AreEqual (new Point (xmin, ymax), m.BottomLeft);
                }
                
                [Test()]
diff --git a/Tests/Core/TestPoint.cs b/Tests/Core/TestPoint.cs
index 4f050de..7260a53 100644
--- a/Tests/Core/TestPoint.cs
+++ b/Tests/Core/TestPoint.cs
@@ -76,6 +76,18 @@ namespace Tests.Core
                        Assert.AreEqual ((double)p1.Y * 100, p2.Y);
                }
 
+               [Test()]
+               public void TestOperators ()
+               {
+                       Point p1 = new Point (2, 4);
+                       Point p2 = new Point (4, 5);
+                       Point p3 = p1 + p2;
+                       Assert.AreEqual (p3.X, 6);
+                       Assert.AreEqual (p3.Y, 9);
+                       p3 = p1 - p2;
+                       Assert.AreEqual (p3.X, -2);
+                       Assert.AreEqual (p3.Y, -1);
+               }
        }
 }
 
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
index 2df3cfc..4a0ba28 100644
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -3,7 +3,16 @@ TARGET = library
 
 LINK = $(REF_DEP_TESTS)
 
-SOURCES = Core/TestColor.cs \
+SOURCES = Core/Drawables/TestAngle.cs \
+       Core/Drawables/TestCross.cs \
+       Core/Drawables/TestDrawable.cs \
+       Core/Drawables/TestEllipse.cs \
+       Core/Drawables/TestLine.cs \
+       Core/Drawables/TestMultipoints.cs \
+       Core/Drawables/TestQuadrilateral.cs \
+       Core/Drawables/TestRectangle.cs \
+       Core/Drawables/TestText.cs \
+       Core/TestColor.cs \
        Core/TestCoordinates.cs \
        Core/TestDashboardButton.cs \
        Core/TestEventType.cs \
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 7b1277e..b273a77 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -56,6 +56,15 @@
     <Compile Include="Core\TestPenaltyCard.cs" />
     <Compile Include="Core\TestScore.cs" />
     <Compile Include="Core\TestPoint.cs" />
+    <Compile Include="Core\Drawables\TestAngle.cs" />
+    <Compile Include="Core\Drawables\TestCross.cs" />
+    <Compile Include="Core\Drawables\TestDrawable.cs" />
+    <Compile Include="Core\Drawables\TestEllipse.cs" />
+    <Compile Include="Core\Drawables\TestLine.cs" />
+    <Compile Include="Core\Drawables\TestMultipoints.cs" />
+    <Compile Include="Core\Drawables\TestQuadrilateral.cs" />
+    <Compile Include="Core\Drawables\TestRectangle.cs" />
+    <Compile Include="Core\Drawables\TestText.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]