public void Log_InitializedProvider_Succeeds()
        {
            // Arrange
            var provider = new MemoryLoggingProvider();

            provider.Initialize("Valid name", CreateValidConfiguration());

            // Act
            provider.Log("Some message");
        }
        public void Log_WithValidEntry_ReturnsAnUniqueNumberPerCall()
        {
            // Arrange
            MemoryLoggingProvider provider = CreateInitializedMemoryLoggingProvider();

            // Act
            int id0 = (int)provider.Log("Valid message");
            int id1 = (int)provider.Log("Valid message");
            int id2 = (int)provider.Log("Valid message");
            int id3 = (int)provider.Log("Valid message");
            int id4 = (int)provider.Log("Valid message");

            // Assert
            Assert.AreEqual(0, id0);
            Assert.AreEqual(1, id1);
            Assert.AreEqual(2, id2);
            Assert.AreEqual(3, id3);
            Assert.AreEqual(4, id4);
        }
        public void Log_ProviderInitializedWithCriticalThresholdThroughConstructor_DoesNotLogMessage()
        {
            // Arrange
            var expectedMessage = "Hello";
            var provider        = new MemoryLoggingProvider(LoggingEventType.Critical);

            // Act
            provider.Log(expectedMessage);

            // Assert
            Assert.AreEqual(0, provider.GetLoggedEntries().Length, "Message was expected not to be logged");
        }
        public void Log_ProviderInitializedWithDebugThresholdThroughConstructor_LogsMessage()
        {
            // Arrange
            var expectedMessage = "Hello";
            var provider        = new MemoryLoggingProvider(LoggingEventType.Debug);

            // Act
            provider.Log(expectedMessage);

            // Assert
            Assert.AreEqual(1, provider.GetLoggedEntries().Length, "Message not logged");
        }
        public void Clear_OnANonEmptyProvivder_ResultsInAnEmptyLoggedEntriesCollection()
        {
            // Arrange
            MemoryLoggingProvider provider = CreateInitializedMemoryLoggingProvider();

            provider.Log("Valid message");
            int expectedNumberOfEntriesAfterCallingClear = 0;

            // Act
            provider.Clear();

            // Assert
            Assert.AreEqual(expectedNumberOfEntriesAfterCallingClear, provider.GetLoggedEntries().Length);
        }
        public void Log_ProviderInitializedWithDefaultConstructor_LogsSuccesfully()
        {
            // Arrange
            string expectedMessage = "Some message";

            var provider = new MemoryLoggingProvider();

            // Act
            // In contrast with most other providers, this provider should succeed in logging the event when
            // it was created with the default constructor, and not initialized with Initialize(string, NVC).
            // This behavior is different, because the the only initialization argument the provider needs is
            // the severity, which will be retain its default value of 'Debug' when not set.
            provider.Log(LoggingEventType.Debug, expectedMessage);

            // Arrange
            Assert.AreEqual(1, provider.GetLoggedEntries().Length, "The provider did not log.");
        }