コード例 #1
0
        static void Main(string[] args)
        {
            var argumentsFactory = new ArgumentsFactory(args,
                                                        ArgumentsConstants.FILE_SIZE_ARGUMENT,
                                                        ArgumentsConstants.BUFFER_LENGTH_ARGUMENT,
                                                        ArgumentsConstants.PATH_ARGUMENT);

            var fileSizeArgument     = argumentsFactory.CreateArgument <FileSizeArgument>(ArgumentsConstants.FILE_SIZE_ARGUMENT);
            var bufferLengthArgument = argumentsFactory.CreateArgument <BufferLengthArgument>(ArgumentsConstants.BUFFER_LENGTH_ARGUMENT);
            var pathArgument         = argumentsFactory.CreateArgument <PathArgument>(ArgumentsConstants.PATH_ARGUMENT);

            Console.WriteLine("Starting application...");

            var crawler = new CrawlerService(new SeleniumService())
                          .Setup();

            var crawlerStatement = new CrawlerStatement(crawler);

            var sentence   = crawlerStatement.GetSentence();
            var bytesCount = crawlerStatement.GetBytesCount(sentence);

            Console.WriteLine("Starting to write in the file using buffer...");

            var writeBuffer = new WriteBuffer(bufferLengthArgument.GetValue())
                              .StringInput(sentence)
                              .BytesCount(bytesCount);

            var report = new FileService(pathArgument.GetValue(), fileSizeArgument.GetValue())
                         .WriteUsingBufferUntilEnd(writeBuffer)
                         .Report();

            Console.WriteLine("Writing to file successfully completed...");

            report.Print();
        }
コード例 #2
0
        public void Should_get_path_argument_correctly()
        {
            var argumentsFactory = new ArgumentsFactory(args, FILE_SIZE_ARGUMENT, BUFFER_LENGTH_ARGUMENT, PATH_ARGUMENT);
            var argument         = argumentsFactory.CreateArgument <PathArgument>(PATH_ARGUMENT);

            Assert.NotNull(argument);
            Assert.Equal(@"D:\dev", argument.GetValue());
        }
コード例 #3
0
        public void Should_get_buffer_length_argument_correctly()
        {
            var argumentsFactory = new ArgumentsFactory(args, ArgumentsConstants.FILE_SIZE_ARGUMENT, ArgumentsConstants.BUFFER_LENGTH_ARGUMENT, ArgumentsConstants.PATH_ARGUMENT);
            var argument         = argumentsFactory.CreateArgument <BufferLengthArgument>(BUFFER_LENGTH_ARGUMENT);

            Assert.NotNull(argument);
            Assert.Equal(10485760L, argument.GetValue());
        }
コード例 #4
0
        public void Should_get_file_size_argument_correctly()
        {
            var argumentsFactory = new ArgumentsFactory(args, ArgumentsConstants.FILE_SIZE_ARGUMENT, ArgumentsConstants.BUFFER_LENGTH_ARGUMENT, ArgumentsConstants.PATH_ARGUMENT);
            var argument         = argumentsFactory.CreateArgument <FileSizeArgument>(FILE_SIZE_ARGUMENT);

            Assert.NotNull(argument);
            Assert.Equal(5242880L, argument.GetValue());
        }
コード例 #5
0
        public void Should_throw_ApplicationArgumentException_when_geting_invalid_argument()
        {
            var argumentsFactory = new ArgumentsFactory(args, ArgumentsConstants.FILE_SIZE_ARGUMENT, ArgumentsConstants.BUFFER_LENGTH_ARGUMENT, ArgumentsConstants.PATH_ARGUMENT);

            Assert.Throws <ApplicationArgumentException>(() => argumentsFactory.CreateArgument <PathArgument>("wrong"));
        }