public void apply_history_when_there_is_prior_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "AlreadyLockedOut",
                Attempts = 3,
                LockedOutTime = DateTime.Today.AddMinutes(30)
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo => repo.Store(history));

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            var request = new LoginRequest
            {
                UserName = history.Id
            };

            auditor.ApplyHistory(request);

            request.NumberOfTries.ShouldBe(history.Attempts);
            request.LockedOutUntil.ShouldBe(history.LockedOutTime.Value);
        }
        public void when_logging_success_wipe_clean_the_login_failure_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "doofus",
                Attempts = 3
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo => { repo.Store(history); });

            var request = new LoginRequest
            {
                Status = LoginStatus.Succeeded,
                UserName = history.Id
            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);
        }
        public void update_an_existing_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "AlreadyFailed",
                Attempts = 2
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo => { repo.Store(history); });

            var request = new LoginRequest
            {
                Status = LoginStatus.Failed,
                UserName = history.Id,
                NumberOfTries = 3,
                LockedOutUntil = DateTime.Today.ToUniversalTime()
            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);

            var history2 = theContainer.GetInstance<IDocumentSession>()
                .Load<LoginFailureHistory>(request.UserName);

            history2.Attempts.ShouldBe(request.NumberOfTries);
            history2.LockedOutTime.ShouldBe(request.LockedOutUntil);
        }