public void AreEquals_Escaping_To_Csharp_format_when_required() { var assertMock = new AreEqualsMethodMock(); Asserter assert = TestHelper.Assert(); assert.Configuration.Test.SetAreEqualsMethod(assertMock.AreEqualsMock); // without " assert.AreEqual("a", "b"); Assert.AreEqual("a", assertMock.Expected); Assert.AreEqual("b", assertMock.Actual); Assert.AreEqual("\r\n\r\nProposed output for unit test:\r\n\r\nvar expected = \"b\";\r\n", assertMock.Message); // with " assert.AreEqual("c", "\"e\""); Assert.AreEqual("c", assertMock.Expected); Assert.AreEqual("\"e\"", assertMock.Actual); Assert.AreEqual("\r\n\r\nProposed output for unit test:\r\n\r\nvar expected = @\"\"\"e\"\"\";\r\n", assertMock.Message); // without " assert.That("aa", Is.EqualTo("bb")); Assert.AreEqual("bb", assertMock.Expected); Assert.AreEqual("aa", assertMock.Actual); Assert.AreEqual("\r\n\r\nProposed output for unit test:\r\n\r\nvar expected = \"aa\";\r\n", assertMock.Message); // with " assert.That("\"cc\"", Is.EqualTo("ee")); Assert.AreEqual("ee", assertMock.Expected); Assert.AreEqual("\"cc\"", assertMock.Actual); Assert.AreEqual("\r\n\r\nProposed output for unit test:\r\n\r\nvar expected = @\"\"\"cc\"\"\";\r\n", assertMock.Message); }
public void TestWhenTwoShapesAreAdjacentThenBottomEdgeWillOnlyBeConsideredToBeInsideOneOfTheShapes() { // Arrange var topLeftFirstShape = SquareFillPoint(x: 1, y: 0); var bottomEdgeFirstShape = SquareFillPoint(x: ShapeConstants.SquareWidth + ShapeConstants.SquareWidth / 2, y: ShapeConstants.SquareWidth); var topLeftSecondShape = SquareFillPoint( x: topLeftFirstShape.X, y: topLeftFirstShape.Y + 1); var firstSquareShape = Shape( topLeftCorner: topLeftFirstShape, squareDefinitions: _singleSquareShapeSquareList1); var secondSquareShape = Shape( topLeftCorner: topLeftSecondShape, squareDefinitions: _singleSquareShapeSquareList2); var shapeList = ShapeList(shape1: secondSquareShape, shape2: firstSquareShape); var shapeSet = ShapeSet(shapes: shapeList); // Act // The bottom edge of the first shape is actually on the border between the two shapes. // But in fact it should be defined is inside the second shape and not inside the first shape. var selectedShape = shapeSet.SelectShape(selectedPoint: bottomEdgeFirstShape); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: secondSquareShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: secondSquareShape.TopLeftCornerY); }
public void TestWhenTwoShapesAreAdjacentThenTopLeftCornerWillOnlyBeConsideredToBeInsideOneOfTheShapes() { // Arrange var topLeftFirstShape = SquareFillPoint(x: 1, y: 0); var topLeftSecondShape = SquareFillPoint( x: topLeftFirstShape.X - 1, y: topLeftFirstShape.Y); var firstSquareShape = Shape( topLeftCorner: topLeftFirstShape, squareDefinitions: _singleSquareShapeSquareList1); var secondSquareShape = Shape( topLeftCorner: topLeftSecondShape, squareDefinitions: _singleSquareShapeSquareList2); var shapeList = ShapeList(shape1: firstSquareShape, shape2: secondSquareShape); var shapeSet = ShapeSet(shapes: shapeList); // Act // The top left corner of the first shape is actually on the border between the two shapes. // But still it should be defined is inside the first shape and not inside the second shape. var selectedShape = shapeSet.SelectShape(selectedPoint: topLeftFirstShape, selectedPointIsGridRef: true); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: firstSquareShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: firstSquareShape.TopLeftCornerY); }
public void TestOccupiedGridSquareMatrixIsCorrectSize() { // Arrange var shapeSetBuilder = new ShapeSetBuilder(squareViewFactory: new MockSquareFactory()); // Act var gridSquares = shapeSetBuilder.MakeGridSquares(); // Assert Asserter.AreEqual(actual: gridSquares.Width, expected: TestConstants.GridWidth); Asserter.AreEqual(actual: gridSquares.Height, expected: TestConstants.GridHeight); }
public void AreEquals_WhenValues_AreAlike_Then_Suggest_change() { var assertMock = new AreEqualsMethodMock(); Asserter assert = TestHelper.Assert(); assert.Configuration.Test.SetAreEqualsMethod(assertMock.AreEqualsMock); foreach (Tuple t in alikeStrings) { assert.AreEqual(t.Item1, t.Item2); Assert.IsTrue(assertMock.Message.StartsWith(AreAlikeNotice)); } }
public void TestAnyLocationOutsideSquareIsNotDefinedAsInsideSquare() { // Arrange var topLeftCorner = SquareFillPoint(x: 0, y: 0); var square = Square(); square.MoveTopLeftCorner(newTopLeftCorner: topLeftCorner); var pointInQuestion = SquareFillPoint(x: topLeftCorner.X + 50, y: topLeftCorner.Y - 10); // Act var isInSquare = square.IsInSquare(point: pointInQuestion); // Assert Asserter.AreEqual(actual: isInSquare, expected: false); }
public void TestPotentialTopLeftCornerIsCalculatedAsParentCornerAdjustedByRelativePosition() { // Arrange var parentTopLeftCorner = SquareFillPoint( x: 4 * TestConstants.SquareWidth, y: 4 * TestConstants.SquareWidth); var square = Square(positionRelativeToParentCorner: SquareFillPoint(x: -2, y: -3), sprite: MockSquareView()); // Act var result = square.CalculatePotentialTopLeftCorner(parentTopLeftCorner: parentTopLeftCorner); // Assert Asserter.AreEqual(actual: result.X, expected: parentTopLeftCorner.X + (square.XRelativeToParentCorner * TestConstants.SquareWidth)); Asserter.AreEqual(actual: result.Y, expected: parentTopLeftCorner.Y + (square.YRelativeToParentCorner * TestConstants.SquareWidth)); }
public void TestAllShapesArePutIntoGridSquares() { // Arrange var topLeftSingleSquare = SquareFillPoint(x: 0, y: 1); var topLeftRightHydrant = SquareFillPoint(x: 1, y: 0); var topLeftCross = SquareFillPoint(x: 5, y: 5); var singleSquare = Shape( topLeftCorner: topLeftSingleSquare, squareDefinitions: _singleSquareShapeSquareList1); var rightHydrant = Shape( topLeftCorner: topLeftRightHydrant, squareDefinitions: _rightHydrantSquareList); var cross = Shape( topLeftCorner: topLeftCross, squareDefinitions: _crossShapeSquareList); var squaresInShapes = new List <List <Square> > { _singleSquareShapeSquareList1, _rightHydrantSquareList, _crossShapeSquareList }; var shapeList = ShapeList(shape1: singleSquare, shape2: rightHydrant, shape3: cross); var shapeSet = ShapeSet(shapes: shapeList); var shapeSetBuilder = new TestShapeSetBuilder(squareViewFactory: new MockSquareFactory()); var occupiedGridSquares = shapeSetBuilder.MakeGridSquares(); // Act shapeSet.OccupyGridSquares(occupiedGridSquares: occupiedGridSquares); // Assert var start1 = 0; var end1 = shapeList.Count - 1; for (int count1 = start1; count1 <= end1; count1++) { var start2 = 0; var end2 = squaresInShapes[count1].Count - 1; for (int count2 = start2; count2 <= end2; count2++) { var square = squaresInShapes[count1][count2]; var xCoord = square.TopLeftCornerX / TestConstants.SquareWidth; var yCoord = square.TopLeftCornerY / TestConstants.SquareWidth; Asserter.AreEqual(actual: occupiedGridSquares.IsSquareOccupied(x: xCoord, y: yCoord), expected: true); } } Asserter.AreEqual(actual: occupiedGridSquares.IsSquareOccupied(x: 0, y: 0), expected: false); }
public void TestCentreOfSquareIsDefinedAsInsideSquare() { // Arrange var centreOfSquare = SquareFillPoint( x: TestConstants.SquareWidth / 2, y: TestConstants.SquareWidth / 2); var topLeftCorner = SquareFillPoint(x: 0, y: 0); var square = Square(); square.MoveTopLeftCorner(newTopLeftCorner: topLeftCorner); // Act var isInSquare = square.IsInSquare(point: centreOfSquare); // Assert Asserter.AreEqual(actual: isInSquare, expected: true); }
public void TestWhenUserClicksInAreaOfScreenWithNoShapeThenNoShapeIsSelected() { // Arrange var topLeftCorner = SquareFillPoint(x: 0, y: 0); var singleSquareShape = Shape( topLeftCorner: topLeftCorner, squareDefinitions: _singleSquareShapeSquareList1); var shapeList = ShapeList(shape: singleSquareShape); var shapeSet = ShapeSet(shapes: shapeList); var selectedPoint = SquareFillPoint(x: TestConstants.SquareWidth * 3 + 10, y: TestConstants.SquareWidth * 3 + 10); // Act var selectedShape = shapeSet.SelectShape(selectedPoint: selectedPoint); // Assert var noShapeSelected = (selectedShape == null); Asserter.AreEqual(actual: noShapeSelected, expected: true); }
public void TestWhenUserClicksInAreaOfScreenWithSingleSquareShapeThenShapeIsSelected() { // Arrange var cornerOfShape = SquareFillPoint( x: 0, y: 0); var topLeftCorner = SquareFillPoint(x: 0, y: 0); var singleSquareShape = Shape( topLeftCorner: topLeftCorner, squareDefinitions: _singleSquareShapeSquareList1); var shapeList = ShapeList(shape: singleSquareShape); var shapeSet = ShapeSet(shapes: shapeList); // Act var selectedShape = shapeSet.SelectShape(selectedPoint: cornerOfShape); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: singleSquareShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: singleSquareShape.TopLeftCornerY); }
public void TestWhenTwoShapesExistThatUserCanSelectTheCorrectShape() { // Arrange var topLeftFirstShape = SquareFillPoint(x: 0, y: 0); var topLeftSecondShape = SquareFillPoint( x: topLeftFirstShape.X + 1, y: topLeftFirstShape.Y + 1); var firstSquareShape = Shape( topLeftCorner: topLeftFirstShape, squareDefinitions: _singleSquareShapeSquareList1); var secondSquareShape = Shape( topLeftCorner: topLeftSecondShape, squareDefinitions: _singleSquareShapeSquareList2); var shapeList = ShapeList(shape1: firstSquareShape, shape2: secondSquareShape); var shapeSet = ShapeSet(shapes: shapeList); // Act var selectedShape = shapeSet.SelectShape(selectedPoint: topLeftSecondShape, selectedPointIsGridRef: true); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: secondSquareShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: secondSquareShape.TopLeftCornerY); }
public void TestWhenCursorIsInNonCornerSquareOfMultipleSquareShapeThenShapeCanStillBeSelected() { // Arrange var topLeftFirstShape = SquareFillPoint(x: 0, y: 1); var topLeftSecondShape = SquareFillPoint(x: 1, y: 0); var firstShape = Shape( topLeftCorner: topLeftFirstShape, squareDefinitions: _singleSquareShapeSquareList1); var secondShape = Shape( topLeftCorner: topLeftSecondShape, squareDefinitions: _rightHydrantSquareList); var shapeList = ShapeList(shape1: firstShape, shape2: secondShape); var shapeSet = ShapeSet(shapes: shapeList); var selectedPoint = SquareFillPoint( x: topLeftSecondShape.X + TestConstants.SquareWidth + 10, y: topLeftSecondShape.Y + TestConstants.SquareWidth + 10); // Act var selectedShape = shapeSet.SelectShape(selectedPoint: selectedPoint); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: secondShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: secondShape.TopLeftCornerY); }
public void TestWhenCursorIsNotInCentreOfSingleSquareShapeThenShapeCanStillBeSelected() { // Arrange var topLeftFirstShape = SquareFillPoint(x: 0, y: 0); var topLeftSecondShape = SquareFillPoint(x: 2, y: 2); var firstSquareShape = Shape( topLeftCorner: topLeftFirstShape, squareDefinitions: _singleSquareShapeSquareList1); var secondSquareShape = Shape( topLeftCorner: topLeftSecondShape, squareDefinitions: _singleSquareShapeSquareList1); var shapeList = ShapeList(shape1: firstSquareShape, shape2: secondSquareShape); var shapeSet = ShapeSet(shapes: shapeList); var selectedPoint = SquareFillPoint( x: (topLeftSecondShape.X * ShapeConstants.SquareWidth) + 1, y: (topLeftSecondShape.Y * ShapeConstants.SquareWidth) + 1); // Act var selectedShape = shapeSet.SelectShape(selectedPoint: selectedPoint); // Assert Asserter.AreEqual(actual: selectedShape.TopLeftCornerX, expected: secondSquareShape.TopLeftCornerX); Asserter.AreEqual(actual: selectedShape.TopLeftCornerY, expected: secondSquareShape.TopLeftCornerY); }
public static void SearchProduct() { model.MainMenu.SearchField.SetValue("adidas België Rode Duivels Thuisshirt - Voetbalshirt - Heren"); model.MainMenu.btn_Search.Click(); Asserter.AreEqual(6, 5, "Validation failed for count on grid"); }