Пример #1
0
        public async Task BeforeAll()
        {
            _batcher = TakeAnItem <int>
                       .Then(CreateFile)
                       .WithThreads(CreateFileThreads)
                       .Then(MoveFile)
                       .WithThreads(MoveFileThreads)
                       .AndFinally(MungeFile)
                       .WithThreads(MungeFileThreads);

            _batcher.Process(1.To(NumberOfFiles));

            var logNext = 0;

            while (true)
            {
                var count = Moved.Pipe(Directory.GetFiles).Pipe(f => f.Length);
                if (count >= logNext)
                {
                    Console.WriteLine($"{count} files moved");
                    logNext += NumberOfFiles / 10;
                }
                if (count >= NumberOfFiles)
                {
                    break;
                }
                await Task.Delay(100);
            }
            Console.WriteLine("**** Files moved ****");
            logNext = 0;
            while (true)
            {
                var count = Munged.Pipe(Directory.GetFiles).Pipe(f => f.Length);
                if (count >= logNext)
                {
                    Console.WriteLine($"{count} files munged");
                    logNext += NumberOfFiles / 10;
                }
                if (count >= NumberOfFiles)
                {
                    break;
                }
                await Task.Delay(100);
            }
            Console.WriteLine("**** Files munged ****");
            _results = 1.To(NumberOfFiles)
                       .Select(GetFilename)
                       .Select(f => Path.Combine(Munged, f))
                       .Select(File.ReadAllText)
                       .Select(JsonConvert.DeserializeObject <List <TaskMetadata> >)
                       .ToList();
        }
        public IBatcher <int> GetBatcher(SynchronicityTestCase synchronicity)
        {
            switch (synchronicity)
            {
            case SynchronicityTestCase.Synchronous:
                return(TakeAnItem <int> .And((Action <int>) ActionSync));

            case SynchronicityTestCase.Asynchronous:
                return(TakeAnItem <int> .And(ActionAsync));

            default:
                throw new NotImplementedException();
            }
        }
Пример #3
0
        public IBatcher <int> GetBatcher(SynchronicityTestCase synchronicity)
        {
            switch (synchronicity)
            {
            case SynchronicityTestCase.Synchronous:
                return(TakeAnItem <int>
                       .Then(Square)
                       .Then(ConvertToStringAsync)
                       .AndFinally((Action <string>)PutInBag));

            case SynchronicityTestCase.Asynchronous:
                return(TakeAnItem <int>
                       .Then(SquareAsync)
                       .Then(ConvertToString)
                       .AndFinally(PutInBagAsync));

            default:
                throw new NotImplementedException();
            }
        }