コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public static void Main()
        {
            var engine = new DealershipEngine();

            engine.Start();
        }