public async void ShouldDiscoverNestedFiles()
        {
            //Arrange
            var config       = ReusableMocks.MockConfig();
            var nestedFolder = Path.Combine(config.Src, Guid.NewGuid().ToString("N"));

            Directory.CreateDirectory(nestedFolder);

            var file = TestUtilities.CreateFile(config.Src, "Example1.doc",
                                                DateTime.Now.Add(config.CurrentTimespan).AddDays(-1));

            var nestedFile = TestUtilities.CreateFile(nestedFolder, "Example2.doc",
                                                      DateTime.Now.Add(config.CurrentTimespan).AddDays(-1));

            var token = new CancellationTokenSource();

            var pipe = new FilePipe(
                config,
                ReusableMocks.MockResultFactory(),
                token.Token);

            //Act
            await pipe.Execute();

            //Assert
            Assert.That(pipe.Buffer.Count == 2);
        }
Пример #2
0
        private static async Task MainAsync()
        {
            var filePipe = new FilePipe(
                Container.Resolve <IConfig>(),
                Container.Resolve <IResultFactory>(),
                ExitToken.Token);

            var metadataPipe = new MetadataPipe(
                Container.Resolve <IConfig>(),
                Container.Resolve <IResultFactory>(),
                filePipe);

            var transferPipe = new TransferPipe(
                Container.Resolve <IConfig>(),
                Container.Resolve <IResultFactory>(),
                metadataPipe);

            var cancelSource = new CancellationTokenSource();

            var ui = Task.Run(() => ReportStatus(Container.Resolve <IResultFactory>(), filePipe, metadataPipe, transferPipe, cancelSource.Token));

            await Task.WhenAll(filePipe.Execute(),
                               metadataPipe.Execute(),
                               transferPipe.Execute());

            cancelSource.Cancel();
            await ui;

            var results = Container.Resolve <IResultFactory>();

            Console.WriteLine("Complete.  Writing index file.");
            results.WriteFile();
        }