private MarketDataSnapshotProcessor(ManageableMarketDataSnapshot snapshot, RemoteEngineContext remoteEngineContext, SnapshotLiveDataStreamInvalidater liveDataStream) { _snapshot = snapshot; _financialClient = remoteEngineContext.CreateFinancialClient(); _marketDataSnapshotMaster = _financialClient.MarketDataSnapshotMaster; _liveDataStream = liveDataStream; _temporarySnapshotUid = new Lazy <UniqueId>(() => _marketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, GetShallowCloneSnapshot())).UniqueId); _snapshotDataStream = new Lazy <SnapshotDataStreamInvalidater>(() => new SnapshotDataStreamInvalidater(_liveDataStream, remoteEngineContext, _temporarySnapshotUid.Value)); }
private MarketDataSnapshotProcessor(ManageableMarketDataSnapshot snapshot, RemoteEngineContext remoteEngineContext, SnapshotLiveDataStreamInvalidater liveDataStream) { _snapshot = snapshot; _financialClient = remoteEngineContext.CreateFinancialClient(); _marketDataSnapshotMaster = _financialClient.MarketDataSnapshotMaster; _liveDataStream = liveDataStream; _temporarySnapshotUid = new Lazy<UniqueId>(() => _marketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, GetShallowCloneSnapshot())).UniqueId); _snapshotDataStream = new Lazy<SnapshotDataStreamInvalidater>(() => new SnapshotDataStreamInvalidater(_liveDataStream, remoteEngineContext, _temporarySnapshotUid.Value)); }
private static void CanAddAndGet(RemoteMarketDataSnapshotMaster snapshotMaster) { var changeManager = snapshotMaster.ChangeManager; var aggregatingChangeListener = new AggregatingChangeListener(); changeManager.AddChangeListener(aggregatingChangeListener); try { var name = TestUtils.GetUniqueName(); var marketDataSnapshotDocument = snapshotMaster.Add(GetDocument(name)); Thread.Sleep(TimeSpan.FromSeconds(1)); List <ChangeEvent> events = aggregatingChangeListener.GetAndClearEvents(); var addEvent = events.Single(e => e.Type == ChangeType.Added && e.AfterId.Equals(marketDataSnapshotDocument.UniqueId)); var retDoc = snapshotMaster.Get(marketDataSnapshotDocument.UniqueId); Assert.NotNull(retDoc); Assert.NotEqual(DateTimeOffset.MinValue, retDoc.VersionFromInstant); Assert.NotEqual(DateTimeOffset.MinValue, retDoc.CorrectionFromInstant); Assert.Equal(retDoc.VersionFromInstant, addEvent.VersionInstant.ToDateTimeOffset()); AssertEqual(retDoc, marketDataSnapshotDocument); snapshotMaster.Remove(marketDataSnapshotDocument.UniqueId); Thread.Sleep(TimeSpan.FromSeconds(1)); events = aggregatingChangeListener.GetAndClearEvents(); var removeEvent = events.Single(e => e.Type == ChangeType.Removed && e.BeforeId.Equals(marketDataSnapshotDocument.UniqueId)); var deleted = snapshotMaster.Get(marketDataSnapshotDocument.UniqueId); Assert.Equal(deleted.VersionToInstant, removeEvent.VersionInstant.ToDateTimeOffset()); } finally { changeManager.RemoveChangeListener(aggregatingChangeListener); } }