示例#1
0
        private static void ReverseApply(out UpdateAction <ManageableMarketDataSnapshot> fwdAction, out WeakReference beforeRef, out WeakReference afterRef)
        {
            var snapshotManager = Context.MarketDataSnapshotManager;

            using (var proc = snapshotManager.CreateFromViewDefinition(RemoteViewClientBatchTests.ViewName))
            {
                using (var newProc = snapshotManager.CreateFromViewDefinition(RemoteViewClientBatchTests.ViewName))
                {
                    //TODO more strict
                    var testedMds      = proc.Snapshot.GlobalValues.Values.First().Key;
                    var valueSnapshots = newProc.Snapshot.GlobalValues.Values[testedMds];
                    valueSnapshots.Remove(valueSnapshots.Keys.First());

                    UpdateAction <ManageableMarketDataSnapshot> fwd = proc.Snapshot.PrepareUpdateFrom(newProc.Snapshot);
                    UpdateAction <ManageableMarketDataSnapshot> bwd = newProc.Snapshot.PrepareUpdateFrom(proc.Snapshot);

                    var pre = proc.Snapshot.GlobalValues.Values[testedMds].ToDictionary(k => k.Key, k => k.Value.MarketValue);

                    fwd.Execute(proc.Snapshot);
                    bwd.Execute(proc.Snapshot);

                    var post = proc.Snapshot.GlobalValues.Values[testedMds].ToDictionary(k => k.Key, k => k.Value.MarketValue);

                    Assert.True(pre.Keys.Concat(post.Keys).All(k => pre[k] == post[k]));

                    bwd.Execute(newProc.Snapshot);
                    fwd.Execute(newProc.Snapshot);

                    beforeRef = new WeakReference(proc.Snapshot);
                    fwdAction = fwd;
                    afterRef  = new WeakReference(newProc.Snapshot);
                }
            }
        }
示例#2
0
        public void VersionedSecuritiesUpdateCorrectlyBasic() //LAP-30
        {
            var before =
                new ManageableUnstructuredMarketDataSnapshot(
                    new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >());
            var update =
                new ManageableUnstructuredMarketDataSnapshot(
                    new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >());

            before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "1")), new Dictionary <string, ValueSnapshot> {
                { "A", new ValueSnapshot(null) }
            });
            update.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "2")), new Dictionary <string, ValueSnapshot> {
                { "A", new ValueSnapshot(null) }
            });

            UpdateAction <ManageableUnstructuredMarketDataSnapshot> prepareUpdateFrom = before.PrepareUpdateFrom(update);

            Assert.Equal(0, prepareUpdateFrom.Warnings.Count());

            prepareUpdateFrom.Execute(before);

            List <UniqueId> updatedIds = before.Values.Keys.Select(m => m.UniqueId).OrderBy(u => u).ToList();
            List <UniqueId> expected   = new[]
            {
                UniqueId.Create("A", "A", "2"),
            }.OrderBy(u => u).ToList();

            Assert.Equal(expected.Count, updatedIds.Count);
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i], updatedIds[i]);
            }
        }
 protected internal override void Execute(XElement configurationElement)
 {
     if (InsertionAction.Exists(configurationElement))
     {
         UpdateAction.Execute(configurationElement.XPathSelectElement(InsertionAction.Selector));
     }
     else
     {
         InsertionAction.Execute(configurationElement);
     }
 }
        public void CanUpdateFromLiveDataStream(ViewDefinition viewDefinition)
        {
            var snapshotManager = Context.MarketDataSnapshotManager;

            using (var dataSnapshotProcessor = snapshotManager.CreateFromViewDefinition(viewDefinition))
            {
                UpdateAction <ManageableMarketDataSnapshot> prepareUpdate = dataSnapshotProcessor.PrepareUpdate();
                var before = GetCount(dataSnapshotProcessor);
                prepareUpdate.Execute(dataSnapshotProcessor.Snapshot);

                var after = GetCount(dataSnapshotProcessor);
                Assert.Equal(before, after);
            }
        }