public void FromSettings_WhenNoNotifiersConfigured_LogsWarning() { var example = NimatorSettings.GetExample(); example.Notifiers = new NotifierSettings[0]; var result = Nimator.FromSettings(loggerMock.Object, example.ToJson()); loggerMock.Verify(l => l.Warn(It.Is <string>(s => s != null && s.ToLowerInvariant().Contains("notifiers")))); }
public void FromSettings_WhenGivenExampleAsJson_ReturnsNimator() { // Bit of a smoke test, but better than nothing... var example = NimatorSettings.GetExample(); var json = example.ToJson(); var result = Nimator.FromSettings(loggerMock.Object, json); Assert.That(result, Is.Not.Null); }
private Nimator(ILog logger, NimatorSettings settings) { if (settings.Notifiers == null || !settings.Notifiers.Any()) { logger.Warn("Zero Notifiers were provided in settings, so results will not be notified to anyone."); } else { this.notifiers = settings.Notifiers.Select(s => s.ToNotifier()).ToList(); } engine = new NimatorEngine(); foreach (var layerSettings in settings.Layers) { var checks = layerSettings.Checks.Select(c => c.ToCheck()).ToList(); engine.AddLayer(layerSettings.Name, checks); } }
/// <summary> /// Constructs a new <see cref="INimator"/> based on a json string that will be /// converted to <see cref="NimatorSettings"/>. /// </summary> /// <param name="logger"> /// Instance that allows Nimator to log errors, warnings, and whatnot. /// </param> /// <param name="json"> /// Any valid json that can be deserialized into <see cref="NimatorSettings"/>. Note that <see cref="Newtonsoft"/> is /// used to deserialize the settings, utilizing TypeNameHandling to determine the specific assemblies and types to pick. /// </param> /// <returns>A bootstrapped <see cref="INimator"/> ready to run cycles.</returns> public static INimator FromSettings(ILog logger, string json) { return(new Nimator(logger, NimatorSettings.FromJson(json))); }