public void CannotNestInlineContexts() { using (IScarfContext context1 = ScarfLogging.BeginInlineContext()) using (IScarfContext context2 = ScarfLogging.BeginInlineContext()) { } }
public void DisposedContextCannotBeUsed() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.Dispose(); context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); } }
public void CannotCreateSeveralAmbientMessages() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); } }
public void NoChangesWithNoCommit() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void NoMessages() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.Commit(); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void OnePrimary_ZeroSecondary() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Access, MessageType.AccessRead); context.Commit(); } Assert.AreEqual(1, dataSource.Messages.Count); }
public void ContextSeparation() { var httpContext1 = CreateHttpContext(); var httpContext2 = CreateHttpContext(); using (IScarfContext context1 = ScarfLogging.BeginInlineContext(httpContext1.Object)) using (IScarfContext context2 = ScarfLogging.BeginInlineContext(httpContext2.Object)) { } }
public void ZeroPrimary_OneSecondary() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfLogging.Debug("Hello world!"); context.Commit(); } Assert.AreEqual(1, dataSource.Messages.Count); }
public void SingleAmbientMessage() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); context.Commit(); } Assert.AreEqual(1, dataSource.Messages.Count); Assert.AreEqual(MessageClass.Debug, dataSource.Messages.First().MessageClass); }
public void Action() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogApiActionAttribute(MessageType.ActionPayment); BeforeAction(attribute); AfterAction(attribute); } Assert.AreEqual(1, dataSource.Messages.Count); }
public void Audit_DetectSuccess() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogAuditAttribute(MessageType.AuditLogin); BeforeAction(attribute); AfterAction(attribute); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void DebugMessage() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfLogging.Debug("Testing"); ScarfLogging.Debug("Testing 123"); context.Commit(); } Assert.AreEqual(2, dataSource.Messages.Count); }
public void Audit_DetectHandledException() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogAuditAttribute(MessageType.AuditLogin); BeforeAction(attribute); ActionThrewException(new InvalidOperationException(), true); AfterAction(attribute); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void AuditFailureWithModelStateErrors_IsLogged() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogAuditAttribute(MessageType.AuditLogin); BeforeAction(attribute); ScarfAudit.Failed(); AfterAction(attribute, true); } Assert.AreEqual(1, dataSource.Messages.Count); }
public void DebugMessages_Disabled() { debugElementMock.SetupGet(d => d.Enabled).Returns(false); using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Debug, MessageType.DebugMessage); context.Commit(); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void AuditMessages_Disabled() { auditElementMock.SetupGet(d => d.Enabled).Returns(false); using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Audit, MessageType.AuditResetPassword); context.Commit(); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void AuditSuccess_IsNotLogged() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogApiAuditAttribute(MessageType.AuditLogin); BeforeAction(attribute); ScarfAudit.LoggedInAs("Test"); AfterAction(attribute); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void ActionWithCodeBasedMessage() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogApiActionAttribute(MessageType.ActionPayment); BeforeAction(attribute); ScarfAction.SetMessage("From code"); AfterAction(attribute); } Assert.AreEqual(1, dataSource.Messages.Count); Assert.AreEqual("From code", dataSource.Messages.Single().Message); }
public void ActionMessages_Enabled() { actionElementMock.SetupGet(d => d.Enabled).Returns(true); using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Action, MessageType.ActionCommand); context.Commit(); } Assert.AreEqual(1, dataSource.Messages.Count); Assert.AreEqual(MessageClass.Action, dataSource.Messages.First().MessageClass); }
public void LogoutAudit() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditLogout); ScarfAudit.LoggedOut("Test"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Audit, msg.MessageClass); Assert.AreEqual(MessageType.AuditLogout, msg.MessageType); }
public void AuditSuccess_EnabledFailuresOnly() { auditElementMock.SetupGet(d => d.Enabled).Returns(true); auditElementMock.SetupGet(d => d.LogOnlyFailures).Returns(true); using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditResetPassword); ScarfAudit.Succeeded(); context.Commit(); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void Action() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAction.Start(MessageType.ActionCommand); ScarfAction.SetMessage("Performed command"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Action, msg.MessageClass); Assert.AreEqual(MessageType.ActionCommand, msg.MessageType); }
public void TestAddCustomInfo() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAction.Start(MessageType.ActionPayment); ScarfLogging.AddCustomInfo("organizationId", "5"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.IsTrue(msg.AdditionalInfo.ContainsKey(ScarfLogMessage.AdditionalInfo_Custom)); Assert.AreEqual("5", msg.AdditionalInfo[ScarfLogMessage.AdditionalInfo_Custom]["organizationId"]); }
public void ResetPasswordAudit() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditResetPassword); ScarfAudit.PasswordReset("Test"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Audit, msg.MessageClass); Assert.AreEqual(MessageType.AuditResetPassword, msg.MessageType); Assert.AreEqual(true, msg.Success.Value); }
public void ActionWithMessage() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogApiActionAttribute(MessageType.ActionPayment) { Message = "Hello there!" }; BeforeAction(attribute); AfterAction(attribute); } Assert.AreEqual(1, dataSource.Messages.Count); Assert.AreEqual("Hello there!", dataSource.Messages.Single().Message); }
public void CreateUserAudit() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditCreateUser); ScarfAudit.UserCreated("Test"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Audit, msg.MessageClass); Assert.AreEqual(MessageType.AuditCreateUser, msg.MessageType); Assert.AreEqual(true, msg.Success.Value); }
public void LoginAuditFailed() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditLogin); ScarfAudit.Failed(); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Audit, msg.MessageClass); Assert.AreEqual(MessageType.AuditLogin, msg.MessageType); Assert.AreEqual(false, msg.Success.Value); }
public void DebugMessages_SettingsNoConflict() { debugElementMock.SetupGet(d => d.Enabled).Returns(false); using (IScarfContext context = ScarfLogging.BeginInlineContext()) { context.CreateMessage(MessageClass.Access, MessageType.AccessRead); context.Commit(); context.CreateMessage(MessageClass.Action, MessageType.ActionCommand); context.Commit(); context.CreateMessage(MessageClass.Audit, MessageType.AuditLogout); context.Commit(); } Assert.AreEqual(3, dataSource.Messages.Count); }
public void ExtractHttpContextInformation() { var httpContext1 = CreateHttpContext(); using (IScarfContext context = ScarfLogging.BeginInlineContext(httpContext1.Object)) { context.CreateMessage(MessageClass.Action, MessageType.ActionPayment); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(RequestPath, msg.ResourceUri); Assert.AreEqual(CurrentUsername, msg.User); Assert.AreEqual(Environment.MachineName, msg.Computer); Assert.AreEqual(ConfigurationMocks.ApplicationName, msg.Application); }