コード例 #1
0
        public void ValueChangesResults()
        {
            var valueRequirement = new ValueRequirement("Market_Value", new ComputationTargetSpecification(ComputationTargetType.Primitive, BloombergUid));

            var defn = GetViewDefinition();

            using (var remoteClient = Context.ViewProcessor.CreateClient())
            {
                var          liveDataOverrideInjector = remoteClient.LiveDataOverrideInjector;
                const double newValue = 1234.5678;

                ManualResetEvent            mre     = new ManualResetEvent(false);
                IViewComputationResultModel results = null;
                var listener = new EventViewResultListener();
                listener.CycleCompleted += delegate(object sender, CycleCompletedArgs e)
                {
                    results = e.FullResult;
                    mre.Set();
                };
                remoteClient.SetResultListener(listener);
                remoteClient.AttachToViewProcess(defn.UniqueID, ExecutionOptions.RealTime);
                liveDataOverrideInjector.AddValue(valueRequirement, newValue);

                mre.WaitOne();
                var result = results.AllResults.Where(
                    r => valueRequirement.IsSatisfiedBy(r.ComputedValue.Specification)).First();
                Assert.Equal(newValue, (double)result.ComputedValue.Value);
            }
        }
        public void ViewHasRightValue()
        {
            ValueRequirement req = GetRequirement();

            using (var remoteClient = Context.CreateFinancialClient())
            {
                ViewDefinition vd = GetViewDefinition(req, TestUtils.GetUniqueName());

                var uid = remoteClient.ViewDefinitionRepository.AddViewDefinition(new AddViewDefinitionRequest(vd));
                Assert.NotNull(uid);
                vd.UniqueID = uid;

                using (var remoteViewClient = Context.ViewProcessor.CreateClient())
                {
                    var viewComputationResultModel = remoteViewClient.GetResults(vd.UniqueID, ExecutionOptions.SingleCycle).First();
                    Assert.NotNull(viewComputationResultModel);
                    var count = viewComputationResultModel.AllResults.Where(spec => req.IsSatisfiedBy(spec.ComputedValue.Specification)).Count();
                    Assert.Equal(1, count);
                }

                remoteClient.ViewDefinitionRepository.RemoveViewDefinition(vd.Name);
            }
        }
コード例 #3
0
        public bool TryGetComputedValue(string calculationConfiguration, ValueRequirement valueRequirement, out ComputedValue result)
        {
            result = null;

            ViewCalculationResultModel model;

            if (!_configurationMap.TryGetValue(calculationConfiguration, out model))
            {
                return(false);
            }

            ISet <ComputedValue> values;

            if (!model.TryGetAllValues(valueRequirement.TargetSpecification, out values))
            {
                return(false);
            }

            var computedValues = values.Where(v => valueRequirement.IsSatisfiedBy(v.Specification));

            result = computedValues.FirstOrDefault();
            return(result != null);
        }