コード例 #1
0
        public void CanRunZeroCycleBatch()
        {
            var runToCompletion = RunToCompletion(ExecutionOptions.Batch(ArbitraryViewCycleExecutionSequence.Create(new DateTimeOffset[] { })));

            Assert.Empty(runToCompletion.Item1);
            Assert.Empty(runToCompletion.Item2);
        }
コード例 #2
0
        public void NumberOfResultsIsConsistent(ViewDefinition defn)
        {
            const int cyclesCount = 5;

            using (var remoteViewClient = Context.ViewProcessor.CreateClient())
                using (var mre = new ManualResetEvent(false))
                {
                    var cycles = new BlockingCollection <IEngineResourceReference <IViewCycle> >();

                    var listener = new EventViewResultListener();
                    listener.ProcessCompleted += delegate { mre.Set(); };
                    listener.ViewDefinitionCompilationFailed += delegate { mre.Set(); };
                    listener.CycleExecutionFailed            += delegate { mre.Set(); };

                    listener.CycleCompleted += (sender, e) =>
                    {
                        cycles.Add(remoteViewClient.CreateCycleReference(e.FullResult.ViewCycleId));
                        remoteViewClient.TriggerCycle();
                    };

                    remoteViewClient.SetResultListener(listener);
                    remoteViewClient.SetViewCycleAccessSupported(true);

                    var sequence = ArbitraryViewCycleExecutionSequence.Create(Enumerable.Range(0, cyclesCount).Select(i => DateTimeOffset.Now + TimeSpan.FromHours(i)));
                    var options  = new ExecutionOptions(sequence, ViewExecutionFlags.TriggersEnabled | ViewExecutionFlags.AwaitMarketData, null, new ViewCycleExecutionOptions(default(DateTimeOffset), ExecutionOptions.GetDefaultMarketDataSpec()));

                    remoteViewClient.AttachToViewProcess(defn.UniqueID, options);

                    TimeSpan timeout = TimeSpan.FromMinutes(5);
                    if (!mre.WaitOne(timeout))
                    {
                        throw new TimeoutException(string.Format("Failed to get result in {0}", timeout));
                    }
                    Assert.Equal(cyclesCount, cycles.Count);

                    var specs = cycles.Select(GetAllSpecs).ToList();

                    var inconsistent = specs.Zip(specs.Skip(1), Tuple.Create).SelectMany(
                        t =>
                    {
                        var diff = new HashSet <Tuple <string, ValueSpecification> >(t.Item1);
                        diff.SymmetricExceptWith(t.Item2);
                        return(diff);
                    }).Distinct();
                    if (inconsistent.Any())
                    {
                        var    counts = string.Join(",", specs.Select(c => c.Count.ToString()));
                        var    inconsistentStrings = specs.Select(s => string.Join(",", s.Where(x => inconsistent.Contains(x)).Select(x => x.ToString())));
                        string inconsistentString  = string.Join(Environment.NewLine, inconsistentStrings);
                        throw new Exception(string.Format("Inconsistent number of results for {0} {1}: {2}", defn.Name, counts, inconsistentString));
                    }
                }
        }
コード例 #3
0
        public void CanRunSingleYesterdayCycleBatchWithVersion()
        {
            DateTimeOffset           valuationTime   = DateTimeOffset.Now - TimeSpan.FromDays(1);
            var                      seq             = ArbitraryViewCycleExecutionSequence.Create(valuationTime);
            const ViewExecutionFlags flags           = ViewExecutionFlags.RunAsFastAsPossible | ViewExecutionFlags.AwaitMarketData;
            IViewExecutionOptions    req             = new ExecutionOptions(seq, flags, defaultExecutionOptions: new ViewCycleExecutionOptions(valuationTime, new LiveMarketDataSpecification()), versionCorrection: new VersionCorrection(valuationTime, valuationTime));
            var                      runToCompletion = RunToCompletion(req);

            Assert.Equal(1, runToCompletion.Item1.Count());
            Assert.Equal(1, runToCompletion.Item2.Count());
            AssertApproximatelyEqual(req.ExecutionSequence.Next.ValuationTime, runToCompletion.Item2.Single().FullResult.ValuationTime);
        }
コード例 #4
0
        public void CanRunManyCycleBatch()
        {
            var valuationTimes = new[]
            {
                DateTimeOffset.Now,
                DateTimeOffset.Now - TimeSpan.FromDays(5),
                DateTimeOffset.Now - TimeSpan.FromDays(1)
            };

            var runToCompletion = RunToCompletion(ExecutionOptions.Batch(ArbitraryViewCycleExecutionSequence.Create(valuationTimes)));

            Assert.Equal(valuationTimes.Count(), runToCompletion.Item2.Count());
            foreach (var t in runToCompletion.Item2.Zip(valuationTimes, Tuple.Create))
            {
                DateTimeOffset expected = t.Item2;
                DateTimeOffset actual   = t.Item1.FullResult.ValuationTime;

                AssertApproximatelyEqual(actual, expected);
            }
        }