public void ReturnCorrectResultFromExecuteCommand_WithCorrectCommandParameters() { var commandLine = "somecommand some parameters"; var commandName = commandLine.Split()[0]; var commandParams = commandLine.Split().Skip(1).ToList(); var commandReturn = "Command executed succesfully!"; var rendererMock = new Mock <IRenderer>(); rendererMock.Setup(x => x.Input()).Returns(new List <string>() { commandLine }); var commandStub = new Mock <ICommand>(); commandStub.Setup(x => x.Execute(commandParams)).Returns(commandReturn); var factoryStub = new Mock <ICommandsFactory>(); factoryStub.Setup(x => x.GetCommand(commandName)).Returns(commandStub.Object); var sut = new FurnitureEngine(rendererMock.Object, factoryStub.Object); sut.Start(); var outputList = new List <string>() { commandReturn }; rendererMock.Verify(x => x.Output(outputList), Times.Once); }
public void CallCreateCommandFactory_WithCorrectCommandName() { var commandLine = "somecommand some parameters"; var commandName = commandLine.Split()[0]; var factoryMock = new Mock <ICommandsFactory>(); var rendererStub = new Mock <IRenderer>(); rendererStub.Setup(x => x.Input()).Returns(new List <string>() { commandLine }); var sut = new FurnitureEngine(rendererStub.Object, factoryMock.Object); sut.Start(); factoryMock.Verify(x => x.GetCommand(commandName), Times.Once); }