public void Accepts_Receiver_argument()
 {
     var anySize = new Size(0, 0);
     var mockLandingSurface = new Mock<ILandingSurface>();
     var landingSurfaceSizeCommand = new LandingSurfaceSizeCommand(anySize);
     Assert.DoesNotThrow(() =>
         landingSurfaceSizeCommand.SetReceiver(mockLandingSurface.Object));
 }
Пример #2
0
        private ICommand ParseLandingSurfaceSizeCommand(string toParse)
        {
            var arguments = toParse.Split(' ');
            var width = int.Parse(arguments[0]);
            var height = int.Parse(arguments[1]);
            var size = new Size(width, height);

            var populatedCommand = landingSurfaceSizeCommandFactory(size);
            return populatedCommand;
        }
Пример #3
0
 public void Given_a_commandString_with_one_LandingSurfaceSizeCommand_creates_LandingSurface_and_sets_size(
     string landingSurfaceSizeCommandString, int expectedWidth, int expectedHeight)
 {
     var expectedSize = new Size(expectedWidth, expectedHeight);
     var commandCenter = container.Resolve<ICommandCenter>();
     commandCenter.Execute(landingSurfaceSizeCommandString);
     var landingSurface = commandCenter.GetLandingSurface();
     var actualSize = landingSurface.GetSize();
     Assert.AreEqual(expectedSize, actualSize);
 }
            public void Sets_LandingSurface_size()
            {
                var mockLandingSurface = new Mock<ILandingSurface>();
                var anySize = new Size(0, 0);
                var landingSurfaceSizeCommand = new LandingSurfaceSizeCommand(anySize);
                landingSurfaceSizeCommand.SetReceiver(mockLandingSurface.Object);

                landingSurfaceSizeCommand.Execute();

                mockLandingSurface.Verify(x => x.SetSize(anySize), Times.Once());
            }
Пример #5
0
            public void Given_invalid_deploy_point_throws_RoverDeployException()
            {
                var aPoint = new Point(0, 0);
                var aSize = new Size(0, 0);

                mockLandingSurface.Setup(x => x.IsValid(aPoint)).Returns(false);
                mockLandingSurface.Setup(x => x.GetSize()).Returns(aSize);
                var rover = new Rover();

                Assert.Throws<RoverDeployException>(() =>
                    rover.Deploy(mockLandingSurface.Object, aPoint, CardinalDirection.West));
            }
Пример #6
0
            public void When_LandingSurfaceSizeCommand_type_returns_new_object_from_factory_with_parsed_values(
                string landingSurfaceSizeCommand, int expectedWidth, int expectedHeight)
            {
                var expectedSize = new Size(expectedWidth, expectedHeight);
                var expectedCommand = new Mock<ILandingSurfaceSizeCommand>();
                Func<Size, ILandingSurfaceSizeCommand> factory = size =>
                {
                    expectedCommand.Setup(x => x.Size).Returns(size);
                    return expectedCommand.Object;
                };
                var mockCommandMatcher = createMockCommandMatcher(CommandType.LandingSurfaceSizeCommand);

                var commandParser = new CommandParser(mockCommandMatcher.Object, factory, null, null);
                var actualCommand = (ILandingSurfaceSizeCommand) commandParser.Parse(landingSurfaceSizeCommand).First();

                Assert.AreEqual(expectedCommand.Object, actualCommand);
                Assert.AreEqual(expectedSize, actualCommand.Size);
            }
 public LandingSurfaceSizeCommand(Size aSize)
 {
     Size = aSize;
 }
 public void Returns_LandingSurfaceSizeCommand_type()
 {
     var size = new Size(0, 0);
     var landingSurfaceSizeCommand = new LandingSurfaceSizeCommand(size);
     Assert.AreEqual(landingSurfaceSizeCommand.GetCommandType(), CommandType.LandingSurfaceSizeCommand);
 }
 public void Given_a_size_argument_exposes_as_public_property()
 {
     var size = new Size(1, 2);
     var landingSurfaceSizeCommand = new LandingSurfaceSizeCommand(size);
     Assert.AreEqual(size, landingSurfaceSizeCommand.Size);
 }