예제 #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);
        }
예제 #2
0
        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);
        }
예제 #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);
        }
예제 #4
0
        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);
        }
예제 #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);
        }
예제 #6
0
        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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #10
0
        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);
        }