Exemplo n.º 1
0
        public void RetrievalType_WithInvalidValue_ThrowsException()
        {
            // Arrange
            var invalidRetrievalType = (UserIdentityRetrievalType)(-1);
            var configuration        = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Act
            configuration.RetrievalType = invalidRetrievalType;
        }
Exemplo n.º 2
0
        public void Constructor_WithValidArguments_Succeeds()
        {
            // Arrange
            var validThreshold        = LoggingEventType.Critical;
            var validConfiguration    = new AspNetSqlLoggingProviderConfiguration("Valid app name");
            var validConnectionString = "Valid constr";

            // Act
            new AspNetSqlLoggingProvider(validThreshold, validConfiguration, validConnectionString, null);
        }
Exemplo n.º 3
0
        public void Constructor_WithValidArguments_InitializesLogQueryStringWithTrue()
        {
            // Arrange
            var expectedLogQueryString = true;

            // Act
            var configuration = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Assert
            Assert.AreEqual(expectedLogQueryString, configuration.LogQueryString);
        }
Exemplo n.º 4
0
        public void Constructor_WithValidArguments_InitializesLogFormDataWithFalse()
        {
            // Arrange
            var expectedLogFormData = false;

            // Act
            var configuration = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Assert
            Assert.AreEqual(expectedLogFormData, configuration.LogFormData);
        }
Exemplo n.º 5
0
        public void Constructor_WithValidArguments_SetsApplicationNameProperty()
        {
            // Arrange
            var expectedApplicationName = "Valid name";

            // Act
            var configuration = new AspNetSqlLoggingProviderConfiguration(expectedApplicationName);

            // Assert
            Assert.AreEqual(expectedApplicationName, configuration.ApplicationName);
        }
Exemplo n.º 6
0
        public void Constructor_WithValidArguments_InitializesRetrievalTypeAsNone()
        {
            // Arrange
            var expectedRetrievalType = UserIdentityRetrievalType.None;

            // Act
            var configuration = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Assert
            Assert.AreEqual(expectedRetrievalType, configuration.RetrievalType);
        }
Exemplo n.º 7
0
        public void LogFormData_ChangingValueToTrue_ShouldSucceed()
        {
            // Arrange
            var expectedValue = true;
            var configuration = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Act
            configuration.LogFormData = expectedValue;

            // Assert
            Assert.AreEqual(expectedValue, configuration.LogFormData);
        }
Exemplo n.º 8
0
        public void LogQueryString_ChangingValueToFalse_ShouldSucceed()
        {
            // Arrange
            var expectedValue = false;
            var configuration = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Act
            configuration.LogQueryString = expectedValue;

            // Assert
            Assert.AreEqual(expectedValue, configuration.LogQueryString);
        }
Exemplo n.º 9
0
        public void RetrievalType_ChangingValue_ShouldSucceed()
        {
            // Arrange
            var expectedRetrievalType = UserIdentityRetrievalType.Membership;
            var configuration         = new AspNetSqlLoggingProviderConfiguration("Valid name");

            // Act
            configuration.RetrievalType = expectedRetrievalType;

            // Arrange
            Assert.AreEqual(expectedRetrievalType, configuration.RetrievalType);
        }
Exemplo n.º 10
0
        public void Constructor_WithValidConfiguration_SetsRetrievalTypeProperty()
        {
            var expectedRetrievalType = UserIdentityRetrievalType.WindowsIdentity;
            var validConfiguration    = new AspNetSqlLoggingProviderConfiguration("Valid app name")
            {
                RetrievalType = expectedRetrievalType
            };

            // Act
            var provider = new AspNetSqlLoggingProvider(LoggingEventType.Critical, validConfiguration,
                                                        "Valid constr", null);

            // Assert
            Assert.AreEqual(expectedRetrievalType, provider.RetrievalType);
        }
Exemplo n.º 11
0
        public void Constructor_WithValidConfiguration_SetsLogFormDataProperty()
        {
            var expectedLogFormData = true;
            var validConfiguration  = new AspNetSqlLoggingProviderConfiguration("Valid app name")
            {
                LogFormData = expectedLogFormData
            };

            // Act
            var provider = new AspNetSqlLoggingProvider(LoggingEventType.Critical, validConfiguration,
                                                        "Valid constr", null);

            // Assert
            Assert.AreEqual(expectedLogFormData, provider.LogFormData);
        }
Exemplo n.º 12
0
        public void Constructor_ChangingLogFormDataInConfigurationAfterConstructorCall_HasNoEffect()
        {
            // Arrange
            var validConfiguration = new AspNetSqlLoggingProviderConfiguration("valid name")
            {
                LogFormData = true
            };

            var provider = new AspNetSqlLoggingProvider(LoggingEventType.Critical, validConfiguration,
                                                        "Valid constr", null);

            // Act
            validConfiguration.LogFormData = false;

            // Assert
            Assert.AreEqual(true, provider.LogFormData);
        }
Exemplo n.º 13
0
        public void Constructor_ChangingRetrievalTypeInConfigurationAfterConstructorCall_HasNoEffect()
        {
            // Arrange
            var validConfiguration = new AspNetSqlLoggingProviderConfiguration("valid name")
            {
                RetrievalType = UserIdentityRetrievalType.None
            };

            var provider = new AspNetSqlLoggingProvider(LoggingEventType.Critical, validConfiguration,
                                                        "Valid constr", null);

            // Act
            validConfiguration.RetrievalType = UserIdentityRetrievalType.Membership;

            // Assert
            Assert.AreEqual(UserIdentityRetrievalType.None, provider.RetrievalType);
        }
Exemplo n.º 14
0
        public void Constructor_WithTooLongApplicationName_ThrowsException()
        {
            // Arrange
            string invalidApplicationName = new string('a', 256);

            try
            {
                // Act
                var configuration = new AspNetSqlLoggingProviderConfiguration(invalidApplicationName);

                // Assert
                Assert.Fail("Exception expected.");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));

                var message = ex.Message;

                Assert.IsTrue(message.Contains("Value is too long"), "Message not descriptive: " + message);
            }
        }