Exemple #1
0
        public void TacitusLogger_Taking_IServiceCollection_When_Called_Sets_Default_LoggerName()
        {
            // Act
            var loggerBuilder = (CustomizedLoggerBuilder)TacitusLoggerExtensionsForMicrosoftDI.TacitusLogger(new Mock <IServiceCollection>().Object);

            // Assert
            Assert.NotNull(loggerBuilder.LoggerName);
        }
Exemple #2
0
        public void TacitusLogger_Taking_IServiceCollection_And_Logger_Name_When_Called_Sets_LoggerName()
        {
            // Arrange
            string loggerName = "logger1";

            // Act
            var loggerBuilder = (CustomizedLoggerBuilder)TacitusLoggerExtensionsForMicrosoftDI.TacitusLogger(new Mock <IServiceCollection>().Object, loggerName);

            // Assert
            Assert.AreEqual(loggerName, loggerBuilder.LoggerName);
        }
Exemple #3
0
        public void TacitusLogger_Taking_IServiceCollection()
        {
            // Arrange
            var serviceCollectionMock = new Mock <IServiceCollection>();

            // Act
            var loggerBuilder = (CustomizedLoggerBuilder)TacitusLoggerExtensionsForMicrosoftDI.TacitusLogger(serviceCollectionMock.Object);

            // Assert
            serviceCollectionMock.Verify(x => x.Add(It.IsAny <ServiceDescriptor>()), Times.Never);
            var logger = loggerBuilder.BuildLogger();

            serviceCollectionMock.Verify(x => x.Add(It.Is <ServiceDescriptor>(d => d.ServiceType == typeof(ILogger) &&
                                                                              d.ImplementationInstance == logger &&
                                                                              d.Lifetime == ServiceLifetime.Singleton)), Times.Once);
        }