Ejemplo n.º 1
0
        public void ObjectDump_WritesObjectContents()
        {
#if ACTIVEDEBUG
            var ied = new IEmergencyDiagnostics();
#else
            var ied = new MockEmergencyDiagnostics();
#endif
            try {
                ied.Log("START OD");
                TestObject to = new TestObject();
                to.stringvalue = "arfle barfle gloop";
                Bilge sut = TestHelper.GetBilgeAndClearDown();
                ied.Log("Before Anything Done");
                var mmh = new MockMessageHandler();
                sut.AddHandler(mmh);

                sut.Info.Dump(to, "context");
                ied.Log("FLUSH OD");
                sut.Flush();
                ied.Log("FlushAfter OD");
                mmh.SetMustContainForBody("arfle barfle gloop");
                ied.Log("ASSERT OD");
                mmh.AssertAllConditionsMetForAllMessages(true, true);
            } finally {
                ied.Log("END OD");
                ied.Shutdown();
            }
        }
Ejemplo n.º 2
0
        public void Bilge_EnterSection_TracesSection()
        {
            var   mmh = new MockMessageHandler();
            Bilge sut = new Bilge(tl: SourceLevels.Verbose);

            sut.AddHandler(mmh);
            mmh.SetMethodNameMustContain("monkeyfish");
            sut.Info.EnterSection("random sectiion", "monkeyfish");
            sut.Flush();

            mmh.AssertAllConditionsMetForAllMessages(true, true);
        }
Ejemplo n.º 3
0
        public void MethodName_MatchesThisMethodName()
        {
            MockMessageHandler mmh = new MockMessageHandler();

            mmh.SetMethodNameMustContain(nameof(MethodName_MatchesThisMethodName));
            Bilge b = TestHelper.GetBilgeAndClearDown();

            b.AddHandler(mmh);
            b.Info.Log("This is a message");
            b.Flush();// (true);
            mmh.AssertAllConditionsMetForAllMessages(true);
        }
Ejemplo n.º 4
0
        public void Bilge_LeaveSection_TracesSection()
        {
            var   mmh = new MockMessageHandler();
            Bilge sut = new Bilge(tl: SourceLevels.Verbose);

            sut.AddHandler(mmh);

            mmh.SetMethodNameMustContain("bannanaball");
            sut.Info.LeaveSection("bannanaball");

            sut.Flush();

            mmh.AssertAllConditionsMetForAllMessages(true, true);
        }
Ejemplo n.º 5
0
        public void Enter_WritesMethodName()
        {
            Bilge sut = TestHelper.GetBilgeAndClearDown();
            var   mmh = new MockMessageHandler();

            sut.AddHandler(mmh);
            sut.Info.E();

            sut.Flush();

            mmh.SetMustContainForBody(nameof(Enter_WritesMethodName));

            // E generates more than one message, therefore we have to check that one of the messages had the name in it.
            mmh.AssertAllConditionsMetForAllMessages(true, true);
        }
Ejemplo n.º 6
0
        public void MultiHandlers_RecieveMultiMessages()
        {
            var mmh1 = new MockMessageHandler();
            var mmh2 = new MockMessageHandler();
            var sut  = TestHelper.GetBilgeAndClearDown();

            sut.AddHandler(mmh1);
            sut.AddHandler(mmh2);

            sut.Info.Flow();
            sut.Flush();

            mmh1.AssertAllConditionsMetForAllMessages(true);
            mmh2.AssertAllConditionsMetForAllMessages(true);
        }
Ejemplo n.º 7
0
        public void Flow_WritesMethodNameToMessage()
        {
            MockMessageHandler mmh = new MockMessageHandler();

            mmh.SetMethodNameMustContain(nameof(Flow_WritesMethodNameToMessage));
            mmh.SetMustContainForBody(nameof(Flow_WritesMethodNameToMessage));
            var sut = TestHelper.GetBilgeAndClearDown();

            sut.ActiveTraceLevel = SourceLevels.Verbose;
            sut.AddHandler(mmh);

            sut.Info.Flow();
            sut.Flush();

            mmh.AssertAllConditionsMetForAllMessages(true);
        }
Ejemplo n.º 8
0
        public void Exit_WritesMethodName()
        {
            var mmh = new MockMessageHandler();

            mmh.SetMethodNameMustContain(nameof(Exit_WritesMethodName));
            Bilge sut = TestHelper.GetBilgeAndClearDown();

            sut.ActiveTraceLevel = SourceLevels.Verbose;
            sut.AddHandler(mmh);
            sut.Info.X();

            sut.Flush();

            // X generates more than one message, therefore we have to check that one of the messages had the name in it.
            mmh.AssertAllConditionsMetForAllMessages(true, true);
        }
Ejemplo n.º 9
0
        public void ProcessId_IsCorrectProcessId()
        {
            int testProcId = Process.GetCurrentProcess().Id;

            MockMessageHandler mmh = new MockMessageHandler();

            mmh.AssertProcessId(testProcId);
            mmh.AssertManagedThreadId(Thread.CurrentThread.ManagedThreadId);
            Bilge sut = TestHelper.GetBilgeAndClearDown();

            sut.AddHandler(mmh);
            sut.Info.Log("Message Written");
            sut.Flush();

            mmh.AssertAllConditionsMetForAllMessages(true);
        }
Ejemplo n.º 10
0
        public void Context_FromConstructorReachesMessage()
        {
            MockMessageHandler mmh     = new MockMessageHandler();
            string             context = "xxCtxtxx";

            mmh.AssertContextIs(context);
            Bilge sut = TestHelper.GetBilgeAndClearDown(context);

            sut.AddHandler(mmh);

            sut.Info.Log("Message should have context");
            sut.Flush();
            Thread.Sleep(1);

            mmh.AssertAllConditionsMetForAllMessages(true);
        }
Ejemplo n.º 11
0
        public void QueuedMessagesWritten_AfterFlush()
        {
            MockMessageHandler mmh = new MockMessageHandler();
            Bilge sut = TestHelper.GetBilgeAndClearDown();

            sut.AddHandler(mmh);
            sut.WriteOnFail = true;
            WriteASeriesOfMessages(sut);

            Assert.Equal <int>(0, mmh.TotalMessagesRecieved);
            sut.TriggerWrite();

            sut.Flush();

            mmh.AssertAllConditionsMetForAllMessages(true);
        }