示例#1
0
        static void Main(string[] args)
        {
            //6,6 as dimensions because end position is 5,1 and as array is 0 based it has to be 6
            LawnField field = new LawnField(6, 6);

            Position mower1Position = new Position(new Ubication(1, 2), new Direction("N"));
            Position mower2Position = new Position(new Ubication(3, 3), new Direction("E"));

            InstructionList mower1ListOfInstructions = new InstructionList("LMLMLMLMM");
            InstructionList mower2ListOfInstructions = new InstructionList("MMRMMRMRRM");

            Mower mower1 = new Mower(mower1Position, mower1ListOfInstructions);
            Mower mower2 = new Mower(mower2Position, mower2ListOfInstructions);

            mower1.NewFieldToBeOperated(field);
            mower2.NewFieldToBeOperated(field);

            mower1.OperateField();
            Console.WriteLine(mower1.GetPosition());

            ACMEMower ACMEmower = new Mower();

            ACMEmower.SaySomething();

            mower1.AskTheField();

            mower2.OperateField();
            Console.WriteLine(mower2.GetPosition());
            mower1.SaySomething();
            mower2.AskTheField();


            Console.Read();
        }
示例#2
0
        public void WhenMowerMoves_OutsideOfFieldBounds_ExceptionShouldBeThrown()
        {
            // Yep, You're right. there was suposed to be code there but for some unkown reason the project was made in .Net Core and i have no idea about net core testin'

            // Arrange
            LawnField field = new LawnField(5, 5);

            Position mower2Position = new Position(new Ubication(3, 3), new Direction("E"));

            InstructionList mower2ListOfInstructions = new InstructionList("MMRMMRMRRM");

            Mower mower2 = new Mower(mower2Position, mower2ListOfInstructions);

            mower2.NewFieldToBeOperated(field);

            // Act
            Exception ex = Assert.Throws <IndexOutOfRangeException>(() => mower2.OperateField());

            // Assert
            Assert.Equal("Woops, You have got out of bounds and cutted the rare plants, you're fired BTW", ex.Message);
        }