Beispiel #1
0
        public void TestEnabled()
        {
            var employer = _employersCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            _userAccountsCommand.EnableUserAccount(employer, Guid.NewGuid());
            _userAccountsCommand.ActivateUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsTrue(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(employer.Id));

            // Disable.

            _userAccountsCommand.DisableUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsFalse(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsFalse(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsFalse(_userAccountsQuery.IsActive(employer.Id));

            // Enable.

            _userAccountsCommand.EnableUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsTrue(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(employer.Id));
        }
Beispiel #2
0
        public void TestEnabled()
        {
            var member = _membersCommand.CreateTestMember(0);

            _userAccountsCommand.EnableUserAccount(member, Guid.NewGuid());
            _userAccountsCommand.ActivateUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsTrue(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(member.Id));

            // Disable.

            _userAccountsCommand.DisableUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsFalse(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsFalse(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsFalse(_userAccountsQuery.IsActive(member.Id));

            // Enable.

            _userAccountsCommand.EnableUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsTrue(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(member.Id));
        }
Beispiel #3
0
        public void TestDisableEnableUserAccount()
        {
            // Create a user and disable it.

            var member = _memberAccountsCommand.CreateTestMember(0);

            Assert.IsTrue(member.IsEnabled);

            var adminId = Guid.NewGuid();

            _userAccountsCommand.DisableUserAccount(member, adminId);

            member = _membersQuery.GetMember(member.Id);
            Assert.IsFalse(member.IsEnabled);

            // Check that the user event was logged.

            AssertDisablement(adminId, member.Id);

            // Enable the user.

            _userAccountsCommand.EnableUserAccount(member, adminId);
            member = _membersQuery.GetMember(member.Id);
            Assert.IsTrue(member.IsEnabled);

            // Check that the user event was logged.

            AssertEnablement(adminId, member.Id);
        }
Beispiel #4
0
        public ActionResult Enable(Guid id)
        {
            var administrator = _administratorsQuery.GetAdministrator(id);

            if (administrator == null)
            {
                return(NotFound("administrator", "id", id));
            }

            _userAccountsCommand.EnableUserAccount(administrator, User.Id().Value);
            return(RedirectToRoute(AdministratorsRoutes.Edit, new { id }));
        }
        public ActionResult Enable(Guid id)
        {
            var employer = _employersQuery.GetEmployer(id);

            if (employer == null)
            {
                return(NotFound("employer", "id", id));
            }

            _userAccountsCommand.EnableUserAccount(employer, User.Id().Value);
            return(RedirectToRoute(EmployersRoutes.Edit, new { id }));
        }
        public ActionResult Enable(Guid id)
        {
            var custodian = _custodiansQuery.GetCustodian(id);

            if (custodian == null)
            {
                return(NotFound("custodian", "id", id));
            }

            _userAccountsCommand.EnableUserAccount(custodian, User.Id().Value);
            return(RedirectToRoute(CustodiansRoutes.Edit, new { id }));
        }
Beispiel #7
0
        public void TestGetEmailMemberUnlockings()
        {
            var channel = _channelsQuery.GetChannel("Web");
            var app     = _channelsQuery.GetChannelApp(channel.Id, "Web");

            Assert.AreEqual(0, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            // Make some contacts.

            var employer1 = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1));

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer1.Id
            });
            var employer2 = _employersCommand.CreateTestEmployer(2, _organisationsCommand.CreateTestOrganisation(2));

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer2.Id
            });

            var member1 = _membersCommand.CreateTestMember(1);

            _userAccountsCommand.EnableUserAccount(member1, Guid.NewGuid());
            member1 = _membersQuery.GetMember(member1.Id);

            var member2 = _membersCommand.CreateTestMember(2);

            _userAccountsCommand.EnableUserAccount(member2, Guid.NewGuid());
            member2 = _membersQuery.GetMember(member2.Id);

            var member3 = _membersCommand.CreateTestMember(3);

            _userAccountsCommand.EnableUserAccount(member3, Guid.NewGuid());
            member3 = _membersQuery.GetMember(member3.Id);

            _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member1), MemberAccessReason.MessageSent);
            Assert.AreEqual(1, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member2), MemberAccessReason.MessageSent);
            Assert.AreEqual(2, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member1), MemberAccessReason.MessageSent);
            Assert.AreEqual(3, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member3), MemberAccessReason.MessageSent);
            Assert.AreEqual(4, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);
        }