public void TestShouldTurnAndMoveInTheRightDirection() { var mf = new MoveForwardCommand(); var tc = new TurnClockwiseCommand(); Tractor tractor = new Tractor(); tc.Execute(tractor); mf.Execute(tractor); Assert.AreEqual(1, tractor.GetPositionX()); Assert.AreEqual(0, tractor.GetPositionY()); tc.Execute(tractor); mf.Execute(tractor); Assert.AreEqual(1, tractor.GetPositionX()); Assert.AreEqual(-1, tractor.GetPositionY()); tc.Execute(tractor); mf.Execute(tractor); Assert.AreEqual(0, tractor.GetPositionX()); Assert.AreEqual(-1, tractor.GetPositionY()); tc.Execute(tractor); mf.Execute(tractor); Assert.AreEqual(0, tractor.GetPositionX()); Assert.AreEqual(0, tractor.GetPositionY()); }
public void TestShouldTurnAndMoveInTheRightDirection() { Tractor tractor = new Tractor(new Field() { Height = 5, Width = 5 }); var moveCommand = new MoveForwardCommand(tractor); var turnCommand = new TurnClockwiseCommand(tractor); turnCommand.Execute(); moveCommand.Execute(); Assert.AreEqual(1, tractor.UnitPosition.X); Assert.AreEqual(0, tractor.UnitPosition.Y); turnCommand.Execute(); moveCommand.Execute(); Assert.AreEqual(1, tractor.UnitPosition.X); Assert.AreEqual(-1, tractor.UnitPosition.Y); turnCommand.Execute(); moveCommand.Execute(); Assert.AreEqual(0, tractor.UnitPosition.X); Assert.AreEqual(-1, tractor.UnitPosition.Y); turnCommand.Execute(); moveCommand.Execute(); Assert.AreEqual(0, tractor.UnitPosition.X); Assert.AreEqual(0, tractor.UnitPosition.Y); }
public void TestShouldTurn() { var tc = new TurnClockwiseCommand(); Wind wind = new Wind(); tc.Execute(wind); Assert.AreEqual(Orientation.East, wind.Orientation); tc.Execute(wind); Assert.AreEqual(Orientation.South, wind.Orientation); tc.Execute(wind); Assert.AreEqual(Orientation.West, wind.Orientation); tc.Execute(wind); Assert.AreEqual(Orientation.North, wind.Orientation); }
public void TestShouldTurn() { var tc = new TurnClockwiseCommand(); Tractor tractor = new Tractor(); tc.Execute(tractor); Assert.AreEqual(Orientation.East, tractor.Orientation); tc.Execute(tractor); Assert.AreEqual(Orientation.South, tractor.Orientation); tc.Execute(tractor); Assert.AreEqual(Orientation.West, tractor.Orientation); tc.Execute(tractor); Assert.AreEqual(Orientation.North, tractor.Orientation); }
public void TestTurnDifferentUnits() { // Поворот _turnCommand.Execute(); _turnCommand.Execute(); _turnCommand.Execute(); // Трактор повернулся Assert.AreEqual(Orientation.West, _tractor.UnitOrientation); // Камень стоит на месте (направления нет) Assert.AreEqual(0, _stone.UnitPosition.X); Assert.AreEqual(0, _stone.UnitPosition.Y); // Ветер поменял направление Assert.AreEqual(Orientation.West, _wind.UnitOrientation); }
public void TestShouldTurn() { Tractor tractor = new Tractor(new Field() { Height = 5, Width = 5 }); var turnCommand = new TurnClockwiseCommand(tractor); turnCommand.Execute(); Assert.AreEqual(Orientation.East, tractor.UnitOrientation); turnCommand.Execute(); Assert.AreEqual(Orientation.South, tractor.UnitOrientation); turnCommand.Execute(); Assert.AreEqual(Orientation.West, tractor.UnitOrientation); turnCommand.Execute(); Assert.AreEqual(Orientation.North, tractor.UnitOrientation); }
public void TestShouldCorrectCommandExec() { var mf = new MoveForwardCommand(); var tc = new TurnClockwiseCommand(); Tractor tractor = new Tractor(); Stone stone = new Stone(new int[] { 2, 4 }); Wind wind = new Wind(); mf.Execute(tractor); mf.Execute(wind); mf.Execute(stone); tc.Execute(tractor); tc.Execute(wind); tc.Execute(stone); Assert.AreEqual(0, tractor.GetPositionX()); Assert.AreEqual(1, tractor.GetPositionY()); Assert.AreEqual(Orientation.East, tractor.Orientation); Assert.AreEqual(Orientation.East, wind.Orientation); Assert.AreEqual(2, stone.GetPositionX()); Assert.AreEqual(4, stone.GetPositionY()); }