public void CheckLayers_WhenAmbientTimeProvderCrashes_WillReturnCriticalResult()
        {
            AmbientTimeProvider.SetNewTimeProvider(() => { throw new Exception("Something truly terrible happened..."); });
            var nimator = new NimatorEngine(new ILayer[0]);

            var result = nimator.RunSafe();

            Assert.That(result.Level, Is.EqualTo(NotificationLevel.Critical));
            Assert.That(result.RenderPlainText(NotificationLevel.Error), Does.Contain("truly terrible"));
        }
        public void SetUp()
        {
            var now = new DateTime(2016, 8, 16, 13, 0, 0);

            AmbientTimeProvider.SetNewTimeProvider(() =>
            {
                now = now.AddMilliseconds(15); // There's 15 ms between each call to the time provider.
                return(now);
            });
        }
        public void CheckLayers_WhenCalled_SetsStartAndEndFromAmbientTimeProvider()
        {
            var now = new DateTime(2016, 8, 16, 13, 0, 0);

            AmbientTimeProvider.SetNewTimeProvider(() =>
            {
                now = now.AddSeconds(15);
                return(now);
            });

            var layer1  = new Mock <ILayer>().WithResult(NotificationLevel.Okay);
            var layer2  = new Mock <ILayer>().WithResult(NotificationLevel.Okay);
            var nimator = new NimatorEngine(new[] { layer1.Object, layer2.Object });

            var result = nimator.RunSafe();

            Assert.That(result.Started, Is.EqualTo(new DateTime(2016, 8, 16, 13, 0, 15)));
            Assert.That(result.Finished, Is.GreaterThan(result.Started));
        }