コード例 #1
0
        public void ControlDataMergeMainTest()
        {
            var helper = new MergeDataHelper();
            var result = helper.MergeData(_testMarketDataDource.ToArray());

            CheckControlDataResult(result);
        }
コード例 #2
0
        public void ControlDataNullInputSourceMainTest()
        {
            var helper = new MergeDataHelper();
            var result = helper.MergeData(null);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 0);
        }
コード例 #3
0
        public void ControlDataMergeMainFourthTest()
        {
            var emptyData = new List <MarketDataUpdate>();

            var helper = new MergeDataHelper();
            var result = helper.MergeData(emptyData.ToArray());

            CheckControlFourthDataResult(result);
        }
コード例 #4
0
        public void ControlDataMergeMainSecondTest()
        {
            var testMarketDataDource = getSecondTestData();

            var helper = new MergeDataHelper();
            var result = helper.MergeData(testMarketDataDource.ToArray());

            CheckSecondControlDataResult(result);
        }
コード例 #5
0
        private void CreateMarketDataProcessingDataFlow()
        {
            _source = new BufferBlock <MarketDataUpdate>(new DataflowBlockOptions()
            {
                BoundedCapacity = DataAggregatorAppSettings.BufferBoundedCapacity
            });
            _batchBlock = new BatchBlock <MarketDataUpdate>(batchSize: DataAggregatorAppSettings.BatchSize, new GroupingDataflowBlockOptions()
            {
                Greedy = true
            });

            _writer = new ActionBlock <List <MarketDataUpdate> >(cd =>
            {
                Console.WriteLine("-------------------------------------------------------");
                cd.ForEach(d => Console.WriteLine(d));
                Console.WriteLine("*******************************************************");
                // snapshot work with current copy data - thread safe.
                _watchers?.ToList().ForEach(watcher => watcher.OnUpdate(cd.ToArray()));
            });

            _transformBlock = new TransformBlock <MarketDataUpdate[], List <MarketDataUpdate> >(e =>
            {
                var helper = new MergeDataHelper();
                return(helper.MergeData(e));
            });

            _source.LinkTo(_batchBlock, new DataflowLinkOptions()
            {
                PropagateCompletion = true
            });

            _batchBlock.LinkTo(_transformBlock, new DataflowLinkOptions()
            {
                PropagateCompletion = true
            });
            _transformBlock.LinkTo(_writer, new DataflowLinkOptions()
            {
                PropagateCompletion = true
            });

            _timer = new Timer(x => {
                _batchBlock.TriggerBatch();
            });
            _timer.Change(DataAggregatorAppSettings.TimerDueTimeMiliseconds, DataAggregatorAppSettings.TimerPeriodMiliseconds);
        }