Beispiel #1
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
        }