Exemplo n.º 1
0
            public void When_executing_RoverDeployCommand_sets_LandingSurface_and_new_Rover_as_command_receivers()
            {
                var expectedRover = new Mock<IRover>();
                var expectedLandingSurface = new Mock<ILandingSurface>();

                var mockRoverDeployCommand = new Mock<IRoverDeployCommand>();
                mockRoverDeployCommand.Setup(x => x.GetCommandType()).Returns(CommandType.RoverDeployCommand);

                Func<IRover> mockRoverFactory = () => expectedRover.Object;

                var commandInvoker = new CommandInvoker(mockRoverFactory);
                commandInvoker.Assign(new[]{mockRoverDeployCommand.Object});
                commandInvoker.SetLandingSurface(expectedLandingSurface.Object);
                commandInvoker.SetRovers(new List<IRover>());

                commandInvoker.InvokeAll();

                mockRoverDeployCommand.Verify(
                    x => x.SetReceivers(expectedRover.Object, expectedLandingSurface.Object), Times.Once());
            }
Exemplo n.º 2
0
            public void When_executing_RoverExploreCommand_sets_most_recently_added_Rover_as_command_receiver()
            {
                var expectedRover = new Mock<IRover>();

                var mockRoverExploreCommand = new Mock<IRoverExploreCommand>();
                mockRoverExploreCommand.Setup(x => x.GetCommandType()).Returns(CommandType.RoverExploreCommand);

                var commandInvoker = new CommandInvoker(null);
                commandInvoker.Assign(new[]{mockRoverExploreCommand.Object});
                commandInvoker.SetRovers(new List<IRover>{ null, expectedRover.Object });

                commandInvoker.InvokeAll();

                mockRoverExploreCommand.Verify(
                    x => x.SetReceiver(expectedRover.Object), Times.Once());
            }
Exemplo n.º 3
0
 public void Accepts_list_of_Rovers()
 {
     var rovers = new IRover[]{};
     var commandInvoker = new CommandInvoker(null);
     Assert.DoesNotThrow(() =>
         commandInvoker.SetRovers(rovers));
 }