public void ApplicationUserAssignJustOnce()
        {
            try
            {
                //the first message is done with wait for commit so we know we've written everything through the publisher before we connect up our event handler.
                Log.Write(LogMessageSeverity.Information, "Loupe", null, null, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Assign Just Once", "Flushing message queue prior to doing resolve once test",
                          "We should get no resolution as we shouldn't have the resolver bound yet.");

                var principal = new GenericPrincipal(new GenericIdentity(Guid.NewGuid().ToString()), null); //we want a unique, but consistent, principal.

                var justOnceProvider = new ResolveUserJustOnceProvider();
                Log.ApplicationUserProvider = justOnceProvider;

                Log.Write(LogMessageSeverity.Information, "Loupe", null, principal, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Assign Just Once",
                          "This message should be attributed to ApplicationUserAssignJustOnce",
                          "And we should get the resolution event following it.");
                Assert.AreEqual(1, justOnceProvider.ResolutionRequests, "We didn't get exactly one resolution after the first message");

                Log.Write(LogMessageSeverity.Information, "Loupe", null, principal, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Assign Just Once",
                          "This message should be attributed to ApplicationUserAssignJustOnce",
                          "And we should NOT get the resolution event following it.");
                Assert.AreEqual(1, justOnceProvider.ResolutionRequests, "We got an additional ResolveApplicationUser event after our initial attempt.");
            }
            finally
            {
                Log.ApplicationUserProvider = null;
            }
        }
        public void Can_Use_Lambda_For_Principal_Resolver()
        {
            try
            {
                //the first message is done with wait for commit so we know we've written everything through the publisher before we connect up our event handler.
                Log.Write(LogMessageSeverity.Information, "Loupe", null, null, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Lambda Principal Resolver", "Flushing message queue prior to doing resolve once test",
                          "We should get no resolution as we shouldn't have the resolver bound yet.");

                Log.PrincipalResolver = new DelegatePrincipalResolver(() => new GenericPrincipal(new GenericIdentity("Can_Use_Lambda_For_Principal_Resolver"), null));
                var justOnceProvider = new ResolveUserJustOnceProvider();
                Log.ApplicationUserProvider = justOnceProvider;

                Log.Write(LogMessageSeverity.Information, "Loupe", null, null, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Lambda Principal Resolver",
                          "This message should be attributed to user Can_Use_Lambda_For_Principal_Resolver",
                          "And we should get the resolution event following it.");
                Assert.AreEqual(1, justOnceProvider.ResolutionRequests, "We didn't get exactly one resolution after the first message");

                Log.Write(LogMessageSeverity.Information, "Loupe", null, null, null,
                          LogWriteMode.WaitForCommit, null, "LogTests.ApplicationUser.Lambda Principal Resolver",
                          "This message should be attributed to user Can_Use_Lambda_For_Principal_Resolver",
                          "And we should NOT get the resolution event following it.");
                Assert.AreEqual(1, justOnceProvider.ResolutionRequests, "We got an additional ResolveApplicationUser event after our initial attempt.");
            }
            finally
            {
                Log.PrincipalResolver       = null;
                Log.ApplicationUserProvider = null;
            }
        }