public void Ctor_ShouldInstantiateEngineCorrectly() { var mockedFactory = new Mock <IDealershipFactory>(); var mockedConsole = new Mock <IConsoleInputOutputProvider>(); var mockedHandler = new Mock <ICommandHandler>(); var engine = new DealershipEngine(mockedFactory.Object, mockedConsole.Object, mockedHandler.Object); Assert.IsInstanceOf <DealershipEngine>(engine); }
public void Start_ShouldReadCommands() { var mockedCommandReader = new Mock <ICommandReader>(); mockedCommandReader.Setup(x => x.ReadCommands()).Returns(new List <ICommand>()); var mockedCommandProcessor = new Mock <ICommandProcessor>(); var mockedReportPrinter = new Mock <IReportPrinter>(); var mockedUserService = new Mock <IUserService>(); var engine = new DealershipEngine(mockedCommandReader.Object, mockedCommandProcessor.Object, mockedReportPrinter.Object, mockedUserService.Object); engine.Start(); mockedCommandReader.Verify(x => x.ReadCommands(), Times.Once); }
public void Reset_ShouldDeleteAllUsers() { var mockedCommandReader = new Mock <ICommandReader>(); var mockedCommandProcessor = new Mock <ICommandProcessor>(); var mockedReportPrinter = new Mock <IReportPrinter>(); mockedReportPrinter.Setup(x => x.PrintReports(It.IsAny <IEnumerable <string> >())); var mockedUserService = new Mock <IUserService>(); mockedUserService.Setup(x => x.DeleteAllUsers()); var engine = new DealershipEngine(mockedCommandReader.Object, mockedCommandProcessor.Object, mockedReportPrinter.Object, mockedUserService.Object); engine.Reset(); mockedUserService.Verify(x => x.DeleteAllUsers(), Times.Once); }
public void Start_ShouldCallCommandManagerProcessCommand_IfCalled() { var writerMock = new Mock <IWriter>(); var dataProviderMock = new Mock <IDataProvider>(); var commandManagerMock = new Mock <ICommandManager>(); var dealershipFactoryMock = new Mock <IDealershipFactory>(); var dealershipEngine = new DealershipEngine( writerMock.Object, dataProviderMock.Object, commandManagerMock.Object, dealershipFactoryMock.Object); dealershipEngine.Start(); commandManagerMock.Verify(x => x.ProcessCommands(It.IsAny <IEnumerable <ICommand> >()), Times.Once); }
public void Start_ShouldCallCommandManagerReadCommands_IfCalled() { var writerMock = new Mock <IWriter>(); var dataProviderMock = new Mock <IDataProvider>(); var commandManagerMock = new Mock <ICommandManager>(); var dealershipFactoryMock = new Mock <IDealershipFactory>(); var dealershipEngine = new DealershipEngine( writerMock.Object, dataProviderMock.Object, commandManagerMock.Object, dealershipFactoryMock.Object); dealershipEngine.Start(); commandManagerMock.Verify(x => x.ReadCommands(), Times.Once); }
public void Start_ShouldPrintReports() { var mockedCommandReader = new Mock <ICommandReader>(); var mockedCommand = new Mock <ICommand>(); mockedCommandReader.Setup(x => x.ReadCommands()).Returns(new List <ICommand>() { mockedCommand.Object }); var mockedCommandProcessor = new Mock <ICommandProcessor>(); mockedCommandProcessor.Setup(x => x.Process(mockedCommand.Object)).Returns("report"); var mockedReportPrinter = new Mock <IReportPrinter>(); mockedReportPrinter.Setup(x => x.PrintReports(It.IsAny <IEnumerable <string> >())); var mockedUserService = new Mock <IUserService>(); var engine = new DealershipEngine(mockedCommandReader.Object, mockedCommandProcessor.Object, mockedReportPrinter.Object, mockedUserService.Object); engine.Start(); mockedReportPrinter.Verify(x => x.PrintReports(It.Is <ICollection <string> >(t => t.Contains("report"))), Times.Once); }
public static void Main() { var engine = new DealershipEngine(); engine.Start(); }