public void AddLayer_WhenPassedIndividualParts_CreatesNewLayer() { var nimator = new NimatorEngine(); var result1 = new CheckResult("check A", NotificationLevel.Warning); var check1 = new Mock <ICheck>(); check1.Setup(c => c.RunAsync()).Returns(result1.AsTaskResult()); nimator.AddLayer("dummy name", new [] { check1.Object }); var result = nimator.RunSafe(); Assert.That(result.Level, Is.EqualTo(NotificationLevel.Warning)); }
public void CheckLayers_WhenOneLayerThrowsAggregateExceptionWithOneInnerException_GetUsefulMessage() { var layer1 = new Mock <ILayer>(); layer1.Setup(l => l.Run()).Throws(new AggregateException(new[] { new Exception("failure1") })); var nimator = new NimatorEngine(); nimator.AddLayer(layer1.Object); var result = nimator.RunSafe(); Assert.That(result.Level, Is.EqualTo(NotificationLevel.Critical)); Assert.That(result.RenderPlainText(NotificationLevel.Critical), Does.Contain("failure1")); }
public void CheckLayers_WhenOneLayerThrowsException_SetsTimes() { var layer1 = new Mock <ILayer>(); layer1.Setup(l => l.Run()).Throws <Exception>(); var nimator = new NimatorEngine(); nimator.AddLayer(layer1.Object); var result = nimator.RunSafe(); Assert.That(result.Level, Is.EqualTo(NotificationLevel.Critical)); Assert.That(result.Started, Is.Not.EqualTo(default(DateTime))); Assert.That(result.Finished, Is.Not.EqualTo(default(DateTime))); }