예제 #1
0
        public void NewStrategy_Should_ImplementICommandOfObjectModel()
        {
            // Arrange
            var factoryMock = new Mock <ICommandFactory <NewStrategy> >();

            // Act
            var objectUnderTest = new NewStrategy(factoryMock.Object);

            // Assert
            Assert.IsInstanceOf <ICommand <ObjectModel> >(objectUnderTest);
        }
예제 #2
0
        public void ShouldReturnCommandName()
        {
            // Arrange
            var factoryMock = new Mock <ICommandFactory <NewStrategy> >();
            var newStrategy = new NewStrategy(factoryMock.Object);

            // Act
            var commandName = newStrategy.Name;

            // Assert
            Assert.AreEqual(commandName, Constants.CommandName.New);
        }
예제 #3
0
        public void ShouldReturnEmptyHelpText()
        {
            // Arrange
            var factoryMock = new Mock <ICommandFactory <NewStrategy> >();
            var newStrategy = new NewStrategy(factoryMock.Object);

            // Act
            var helpText = newStrategy.GetHelpText();

            // Assert
            Assert.AreEqual(helpText, Resources.text.help.HelpTextValues.NewCommand);
        }
예제 #4
0
        public void NewStrategy_Should_ExecuteChildCommand([ValueSource(nameof(Data))] NewStrategyFixture data)
        {
            // Arrange
            var commandMock = new Mock <ICommand <NewStrategy> >();

            commandMock.Setup(x => x.Execute(It.IsAny <IEnumerable <string> >())).Returns(new CommandResult(true, new MessageLines {
                { data.Result, string.Empty }
            }));
            var factoryMock = new Mock <ICommandFactory <NewStrategy> >();

            factoryMock.Setup(x => x.GetCommand(data.Input.FirstOrDefault())).Returns(commandMock.Object);
            var objectUnderTest = new NewStrategy(factoryMock.Object);

            // Act
            var result = objectUnderTest.Execute(data.Input);

            // Assert
            Assert.IsTrue(result.Success);
            Assert.AreEqual(data.Result, result.OutputMessages.First().Key);
        }