public void TestDictionary() { string str = "This is a Dictionary payload"; Event @event = new CommanderLoadingEvent(DateTime.UtcNow, "testCmdr", "F111111"); Exception exception = new InvalidCastException(); Dictionary <string, object> data = new Dictionary <string, object>(); data.Add("message", str); data.Add("event", @event); data.Add("exception", exception); Dictionary <string, object> result = PrepRollbarData(data); result.TryGetValue("message", out object message); Assert.AreEqual(str, message?.ToString()); result.TryGetValue("event", out object theEvent); ((JObject)theEvent).TryGetValue("frontierID", out JToken frontierID); Assert.IsNull(frontierID?.ToString()); ((JObject)theEvent).TryGetValue("type", out JToken type); Assert.IsNotNull(type); Assert.AreEqual(@event.type, type?.ToString()); result.TryGetValue("exception", out object theException); ((JObject)theException).TryGetValue("Message", out JToken theExceptionMessage); Assert.AreEqual(exception.Message, theExceptionMessage?.ToString()); }
public void TestOther() { Event data = new CommanderLoadingEvent(DateTime.UtcNow, "testCmdr", "F111111"); Dictionary <string, object> result = PrepRollbarData(data); Assert.IsFalse(result.TryGetValue("frontierID", out object frontierID), "'frontierID' property should have been removed"); Assert.IsTrue(result.TryGetValue("type", out object type)); }