private void AssertEvents(EventCapturer actualEvents, BsonDocument test, Dictionary <string, BsonValue> sessionIdMap) { Logger.Debug("Asserting events"); if (test.Contains("expectations")) { var expectedEvents = test["expectations"].AsBsonArray.Cast <BsonDocument>().GetEnumerator(); while (actualEvents.Any()) { var actualEvent = actualEvents.Next(); if (!expectedEvents.MoveNext()) { throw new Exception($"Unexpected event of type: {actualEvent.GetType().Name}."); } var expectedEvent = expectedEvents.Current; RecursiveFieldSetter.SetAll(expectedEvent, "lsid", value => sessionIdMap[value.AsString]); AssertEvent(actualEvent, expectedEvent); } if (expectedEvents.MoveNext()) { var expectedEvent = expectedEvents.Current; throw new Exception($"Missing event: {expectedEvent}."); } } }
private void AssertEvents(EventCapturer actualEvents, BsonDocument test, Dictionary <string, BsonValue> sessionIdMap) { if (test.Contains("expectations")) { foreach (var expectedEvent in test["expectations"].AsBsonArray.Cast <BsonDocument>()) { RecursiveFieldSetter.SetAll(expectedEvent, "lsid", value => sessionIdMap[value.AsString]); var actualEvent = actualEvents.Next(); AssertEvent(actualEvent, expectedEvent); } } }
protected override void AssertEvent(object actualEvent, BsonDocument expectedEvent) { base.AssertEvent( actualEvent, expectedEvent, (actual, expected) => { RecursiveFieldSetter.SetAll( expected, "lsid", value => { if (ObjectMap.TryGetValue(value.AsString + SessionIdKeySuffix, out var sessionId)) { return((BsonValue)sessionId); } else { return(value); } }); }); }
protected override void AssertEvents(EventCapturer actualEvents, BsonDocument test) { base.AssertEvents( actualEvents, test, document => { RecursiveFieldSetter.SetAll( document, "lsid", value => { if (ObjectMap.TryGetValue(value.AsString + SessionIdKeySuffix, out var sessionId)) { return((BsonValue)sessionId); } else { return(value); } }); }); }