Beispiel #1
0
            public void GoodWarningLogNoException_CallsPublishToQueue()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);

                // act
                log.WriteWarningLog("test");

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.IsAny <LogMessage>()), Times.Once, "Not called with expected LogMessage");
            }
Beispiel #2
0
            public void GoodWarningLogNoException_HasProperSeverity()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                int expected = 2;

                // act
                log.WriteWarningLog("test");

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.EntryType.Id.Equals(expected))),
                        Times.Once,
                        "Severity level not set properly");
            }
Beispiel #3
0
            public void GoodWarningLogNoException_HasProperEnvironment()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                string expected = ConfigurationHelper.GetActiveConfiguration();

                // act
                log.WriteWarningLog("test");

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Application.Environment.Equals(expected))),
                        Times.Once,
                        "Application Environment not set properly");
            }
Beispiel #4
0
            public void GoodWarningLogNoException_HasMessage()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                string expected = "test";

                // act
                log.WriteWarningLog("test");

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Message.Equals(expected))),
                        Times.Once,
                        "Message was not set properly");
            }
Beispiel #5
0
            public void GoodWarningLogNoException_HasApplicationName()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                string expected = ConfigurationManager.AppSettings["AppName"];

                // act
                log.WriteWarningLog("test");

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Application.Name.Equals(expected))),
                        Times.Once,
                        "Application Name not set properly");
            }
Beispiel #6
0
            public void GoodWarningLog_CallsPublishToQueueWithExceptionMessage()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                string expected = "Something went wrong!";

                // act
                log.WriteWarningLog(expected, MakeException());

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Message.Equals(expected))),
                        Times.Once,
                        "Message did not match");
            }
Beispiel #7
0
            public void GoodWarningLog_CallsPublishToQueueAndSetsStackTrace()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                Exception exception             = MakeException();

                // act
                log.WriteWarningLog("Ooops!", exception);

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Exception.StackTrace.Length > 0)),
                        Times.Once,
                        "StackTrace is not being set");
            }
Beispiel #8
0
            public void GoodWarningLog_CallsPublishToQueueAndSetsMachineName()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                Exception exception             = MakeException();

                // act
                log.WriteWarningLog("Oops!", exception);

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.Machine.Name.Length > 0)),
                        Times.Once(),
                        "Machine name did not get set");
            }
Beispiel #9
0
            public void GoodWarningLog_HasTheProperSeverity()
            {
                // arrange
                MockDependents dependents       = MakeMockDependents();
                EventLogQueueRepositoryImpl log = new EventLogQueueRepositoryImpl(dependents.QueueRepository.Object);
                Exception exception             = MakeException();
                int       expectedSeverity      = 2;

                // act
                log.WriteWarningLog("Oops!", exception);

                // assert
                dependents.QueueRepository
                .Verify(x => x.PublishLogMessage(It.Is <LogMessage>(m => m.EntryType.Id.Equals(expectedSeverity))),
                        Times.Once(),
                        "Severity level not set to information");
            }