コード例 #1
0
        public void Show_UserEntersExit_ShowsFirstPageAndExits()
        {
            var userCommands = Substitute.For<UserCommands>();
            var userStub = Substitute.For<User>();
            var sut = new CsvViewer(userStub, userCommands);

            userStub.EnteredCommand().Returns(new ExitCommand());

            sut.Execute();

            userCommands.Received(1).FirstPage();
            userCommands.DidNotReceive().Execute(Arg.Any<UserCommand>());
        }
コード例 #2
0
        public void Show_UserEntersPrevious_ShowsPreviousPageAndExits()
        {
            var userCommands = Substitute.For<UserCommands>();
            var user = Substitute.For<User>();
            var sut = new CsvViewer(user, userCommands);

            user.EnteredCommand().Returns(new PreviousPageCommand(null, null), new ExitCommand());

            sut.Execute();

            userCommands.Received(1).FirstPage();
            userCommands.Received(1).Execute(new PreviousPageCommand(null, null));
            userCommands.DidNotReceive().Execute(new ExitCommand());
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            List<DataRecord> dataRecords = new CsvFileConverter().ToDataRecords(args[FILE_NAME]);

            var userCommands = new CsvUserCommands(
                new ConsoleDisplay(),
                new Table(
                    dataRecords,
                    defaultPageSize: new PageSizeAgent(
                        defaultPageSize: 3,
                        indexOfPageSize: 1).DetectPageSize(args)));

            var csvViewer = new CsvViewer(
                new ConsoleUser(user, userCommands),
                userCommands);

            csvViewer.Execute();
        }