public void Serialization_WhenGivenCustomExample_CanDoRoundTrip() { var settings = new NimatorSettings { Notifiers = new NotifierSettings[] { new OpsGenieSettings { Threshold = NotificationLevel.Error, ApiKey = "abc-123", HeartbeatName = "heartbeat", TeamName = "A-Team" }, new SlackSettings { Threshold = NotificationLevel.Warning, Url = "http://www.cp.nl/dummy/url", }, new ConsoleSettings { Threshold = NotificationLevel.Warning, } }, Layers = new LayerSettings[] { new LayerSettings { Name = "Layer A", Checks = new ICheckSettings[] { new NoopCheckSettings { DelayResultInMs = 500, LevelToSimulate = NotificationLevel.Error, }, } } }, }; var json = settings.ToJson(); var roundTripSettings = NimatorSettings.FromJson(json); var roundTripJson = roundTripSettings.ToJson(); Assert.That(json, Is.EqualTo(roundTripJson)); }
public void Serialization_WhenGivenDataWithEnum_RendersEnumAsString() { var settings = new NimatorSettings { Layers = new LayerSettings[] { new LayerSettings { Name = "Layer 1", Checks = new ICheckSettings[] { new NoopCheckSettings { LevelToSimulate = NotificationLevel.Warning }, }, }, }, }; var json = settings.ToJson(); Assert.That(json, Does.Contain("Warning"), "Expected readable representation of enum value"); }