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); }
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); }
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); }
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); }
public void Log_UninitializedProvider_ThrowsDescriptiveException() { // Arrange var provider = new AspNetSqlLoggingProvider(); try { // Act provider.Log("Some message"); // Assert Assert.Fail("Exception expected."); } catch (InvalidOperationException ex) { Assert.IsTrue(ex.Message.Contains("The provider has not been initialized"), "A provider that hasn't been initialized correctly, should throw a descriptive " + "exception. Actual: " + ex.Message + Environment.NewLine + ex.StackTrace); Assert.IsTrue(ex.Message.Contains("AspNetSqlLoggingProvider"), "The message should contain the type name of the unitialized provider. Actual: " + ex.Message); } }