예제 #1
0
        public void Should_Change_Position_West_When_ForwardInstruction_Moves()
        {
            int         move        = 1;
            int         xPos        = 5;
            Orientation orientation = Orientation.West;

            ShipPosition       position    = new ShipPosition(xPos, 5, orientation);
            ForwardInstruction instruction = new ForwardInstruction(move, topRight, bottomLeft);

            //test
            ShipPosition actual = instruction.Move(position);

            //assert
            Assert.AreEqual(orientation, actual.Orientation, "orientation should not have moved");
            Assert.AreEqual(xPos - 1, actual.X, "ship should have moved x corordinate");
            Assert.AreEqual(position.Y, actual.Y, "ship should not have moved y corordinate");
            Assert.AreEqual(false, actual.Lost, "ship should not be lost");
        }
예제 #2
0
        public void Should_Mark_As_Lost_When_ForwardInstruction_Moves_West_Over_Boarder()
        {
            int         move        = 1;
            int         xPos        = bottomLeft.X;
            Orientation orientation = Orientation.West;

            ShipPosition       position    = new ShipPosition(xPos, 5, orientation);
            ForwardInstruction instruction = new ForwardInstruction(move, topRight, bottomLeft);

            //test
            ShipPosition actual = instruction.Move(position);

            //assert
            Assert.AreEqual(orientation, actual.Orientation, "orientation should not have moved");
            Assert.AreEqual(position.X, actual.X, "ship should not have moved x corordinate");
            Assert.AreEqual(position.Y, actual.Y, "ship should not have moved x corordinate");
            Assert.AreEqual(true, actual.Lost, "ship should not be lost");
        }