Пример #1
0
        public void Run()
        {
            if (!CanRun())
            {
                throw new ArgumentException("Cannot run with that file name");
            }

            NameSorterScreenUtils screenUtils = new NameSorterScreenUtils(NameDetailsLineBuilder);

            NameSorterCommand command = new NameSorterCommand(FileUtils, screenUtils, ExecutionState);

            command.run(FileName, "sorted-names-list.txt");
        }
        public void RunEndToEndProcess1()
        {
            String expectedLine1 = "Mad as a hatter Max";
            String expectedLine2 = "Modonna Smith";
            String expectedLine3 = "John Snow";

            List <String> fileContent = new List <String>();

            fileContent.Add(expectedLine3);
            fileContent.Add(expectedLine1);
            fileContent.Add(expectedLine2);

            NameSorterLinesProcess  process     = new NameSorterLinesProcess(nameDetailsLineBuilder);
            NameSorterFileUtilsMock fileUtils   = new NameSorterFileUtilsMock(process, "test1.txt", fileContent);
            NameSorterScreenUtils   screenUtils = new NameSorterScreenUtils(nameDetailsLineBuilder);
            ExecutionStateMock      stateMock   = new ExecutionStateMock();

            NameSorterCommand command = new NameSorterCommand(fileUtils, screenUtils, stateMock);

            command.run("test1.txt", "test1.done.txt");

            List <String> linesWritten = fileUtils.LastLinesWritten;

            Assert.Equal(3, linesWritten.Count);

            String line1 = linesWritten[0];

            Assert.Equal(expectedLine1, line1);

            String line2 = linesWritten[1];

            Assert.Equal(expectedLine2, line2);

            String line3 = linesWritten[2];

            Assert.Equal(expectedLine3, line3);
        }