public void DoesNotLogFirstError() { var ignorant = new Ignorant { SilencePeriods = new[] { TimeSpan.FromMinutes(1) } }; var isToBeIgnored = ignorant.IsToBeIgnored(new ApplicationException("hej")); Assert.That(isToBeIgnored, Is.True); }
public void BuildIgnoresClassWithoutInterface() { var strategy = new BuilderAwareStrategy(); var context = new MockBuilderContext(); var obj = new Ignorant(); context.Strategies.Add(strategy); context.ExecuteBuildUp(new NamedTypeBuildKey<Ignorant>(), obj); Assert.IsFalse(obj.OnBuiltUp__Called); Assert.IsFalse(obj.OnTearingDown__Called); }
public void TearDownIgnoresClassWithoutInterface() { BuilderAwareStrategy strategy = new BuilderAwareStrategy(); MockBuilderContext context = new MockBuilderContext(); Ignorant obj = new Ignorant(); context.Strategies.Add(strategy); context.HeadOfChain.TearDown(context, obj); Assert.False(obj.OnBuiltUp__Called); Assert.False(obj.OnTearingDown__Called); }
public void TearDownIgnoresClassWithoutInterface() { var strategy = new BuilderAwareStrategy(); var context = new MockBuilderContext(); var obj = new Ignorant(); context.Strategies.Add(strategy); context.ExecuteTearDown(obj); Assert.False(obj.OnBuiltUpWasCalled); Assert.False(obj.OnTearingDownWasCalled); }
public void BuildIgnoresClassWithoutInterface() { BuilderAwareStrategy strategy = new BuilderAwareStrategy(); MockBuilderContext context = new MockBuilderContext(); Ignorant obj = new Ignorant(); context.Strategies.Add(strategy); context.ExecuteBuildUp(typeof(Ignorant), obj); Assert.IsFalse(obj.OnBuiltUp__Called); Assert.IsFalse(obj.OnTearingDown__Called); }
public void BuildIgnoresClassWithoutInterface() { var strategy = new BuilderAwareStrategy(); var context = new MockBuilderContext(); var obj = new Ignorant(); context.Strategies.Add(strategy); context.ExecuteBuildUp(new NamedTypeBuildKey <Ignorant>(), obj); Assert.IsFalse(obj.OnBuiltUp__Called); Assert.IsFalse(obj.OnTearingDown__Called); }
public void LogsAfterSilencePeriodIsOver() { var now = DateTime.UtcNow; var ignorant = new Ignorant { SilencePeriods = new[] { TimeSpan.FromMinutes(1) } }; RebusTimeMachine.FakeIt(now); var first = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(1.1)); var second = ignorant.IsToBeIgnored(new ApplicationException("hej")); Assert.That(first, Is.True); Assert.That(second, Is.False); }
public void GoesOnToNextSilencePeriodAfterTheFirstHasElapsed() { var now = DateTime.UtcNow; var ignorant = new Ignorant { SilencePeriods = new[] { TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(10) } }; RebusTimeMachine.FakeIt(now); var first = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(1.1)); var second = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(11.1)); var third = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(11.2)); var fourth = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(21.2)); var fifth = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(21.3)); var sixth = ignorant.IsToBeIgnored(new ApplicationException("hej")); Assert.That(first, Is.True); Assert.That(second, Is.False); Assert.That(third, Is.True); Assert.That(fourth, Is.False); Assert.That(fifth, Is.True); Assert.That(sixth, Is.False); }
public void ResetsWhenResetIsCalled() { var now = DateTime.UtcNow; var ignorant = new Ignorant { SilencePeriods = new[] { TimeSpan.FromMinutes(1) } }; RebusTimeMachine.FakeIt(now); var first = ignorant.IsToBeIgnored(new ApplicationException("hej")); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(0.9)); var second = ignorant.IsToBeIgnored(new ApplicationException("hej")); ignorant.Reset(); RebusTimeMachine.FakeIt(now + TimeSpan.FromMinutes(1.1)); var third = ignorant.IsToBeIgnored(new ApplicationException("hej")); Assert.That(first, Is.True); Assert.That(second, Is.True); Assert.That(third, Is.True); }
public void TearDownIgnoresClassWithoutInterface() { var strategy = new BuilderAwareStrategy(); var context = new MockBuilderContext(); var obj = new Ignorant(); context.Strategies.Add(strategy); context.ExecuteTearDown(obj); Assert.IsFalse(obj.OnBuiltUpWasCalled); Assert.IsFalse(obj.OnTearingDownWasCalled); }