Browse Source

Fixed test

flabbet 5 years ago
parent
commit
02004be5c5

+ 2 - 2
PixiEditor/Models/Position/CoordinatesCalculator.cs

@@ -34,8 +34,8 @@ namespace PixiEditor.Models.Position
 
 
         public static Coordinates GetCenterPoint(Coordinates startingPoint, Coordinates endPoint)
         public static Coordinates GetCenterPoint(Coordinates startingPoint, Coordinates endPoint)
         {
         {
-            int x = (int)Math.Truncate((startingPoint.X + endPoint.X) / 2f);
-            int y = (int)Math.Truncate((startingPoint.Y + endPoint.Y) / 2f);
+            int x = (int)Math.Floor((startingPoint.X + endPoint.X) / 2f);
+            int y = (int)Math.Floor((startingPoint.Y + endPoint.Y) / 2f);
             return new Coordinates(x, y);
             return new Coordinates(x, y);
         }
         }
 
 

+ 2 - 2
PixiEditorTests/ModelsTests/PositionTests/CoordinatesCalculatorTests.cs

@@ -6,14 +6,14 @@ namespace PixiEditorTests.ModelsTests.PositionTests
     [TestFixture]
     [TestFixture]
     public class CoordinatesCalculatorTests
     public class CoordinatesCalculatorTests
     {
     {
-        [TestCase(0, 0, 3, 3, 2, 2)]
+        [TestCase(0, 0, 3, 3, 1, 1)]
         [TestCase(0, 0, 2, 2, 1, 1)]
         [TestCase(0, 0, 2, 2, 1, 1)]
         [TestCase(5, 5, 7, 7, 6, 6)]
         [TestCase(5, 5, 7, 7, 6, 6)]
         [TestCase(5, 5, 9, 9, 7, 7)]
         [TestCase(5, 5, 9, 9, 7, 7)]
         public void TestGetCenter(int x1, int y1, int x2, int y2, int expectedX, int expectedY)
         public void TestGetCenter(int x1, int y1, int x2, int y2, int expectedX, int expectedY)
         {
         {
             Coordinates center = CoordinatesCalculator.GetCenterPoint(new Coordinates(x1, y1), new Coordinates(x2, y2));
             Coordinates center = CoordinatesCalculator.GetCenterPoint(new Coordinates(x1, y1), new Coordinates(x2, y2));
-            Assert.AreEqual(center, new Coordinates(expectedX, expectedY));
+            Assert.AreEqual(new Coordinates(expectedX, expectedY), center);
         }
         }
 
 
     }
     }