public void GivenUserHasProviderAssociations_AndUserHasSchoolAssociations_WhenIExecuteDataSelector_ThenAssociationsIsSumOfSchoolAssociationCountAndProviderAssociationCount() { UserClientDataTable target = new UserClientDataTable(MockRequest, SecurityConfiguration); var schools = new List <School> { new School(), new School() }; var providers = new List <Provider> { new Provider(), new Provider(), new Provider() }; User user = new User { UserRoles = new List <UserRole> { new UserRole { Role = new Role(), Schools = schools, Providers = providers } } }; SecurityConfiguration.Expect(m => m.AdministratorEmailAddresses).Return(new string[] { "*****@*****.**" }); dynamic actual = target.DataSelector.Compile().Invoke(user); Assert.AreEqual(schools.Count + providers.Count, actual.Associations); }
public void GivenUserIsNotConfiguredAsAdministrator_WhenIExecuteDataSelector_ThenDataRolesDoesNotContainAdministrator() { UserClientDataTable target = new UserClientDataTable(MockRequest, SecurityConfiguration); User user = new User { EmailAddress = "*****@*****.**" }; SecurityConfiguration.Expect(m => m.AdministratorEmailAddresses).Return(new string[] { "*****@*****.**" }); dynamic actual = target.DataSelector.Compile().Invoke(user); Assert.IsFalse(((IEnumerable <string>)actual.Roles).Contains(SecurityRoles.Administrator)); }
public void GivenUserIsConfiguredAsAdministrator_WhenIExecuteDataSelector_ThenDataRolesIsAdministrator() { UserClientDataTable target = new UserClientDataTable(MockRequest, SecurityConfiguration); User user = new User { EmailAddress = "*****@*****.**" }; SecurityConfiguration.Expect(m => m.AdministratorEmailAddresses).Return(new string[] { user.EmailAddress }); dynamic actual = target.DataSelector.Compile().Invoke(user); Assert.AreEqual(SecurityRoles.Administrator, ((IEnumerable <string>)actual.Roles).Single()); }
public void GivenUserHasLoginEvents_WhenIExecuteDataSelector_ThenDataHasLastLoginTime() { UserClientDataTable target = new UserClientDataTable(MockRequest, SecurityConfiguration); User user = new User { LoginEvents = new List <LoginEvent> { new LoginEvent { CreateTime = DateTime.Now } } }; SecurityConfiguration.Expect(m => m.AdministratorEmailAddresses).Return(new string[] { user.EmailAddress }); dynamic actual = target.DataSelector.Compile().Invoke(user); Assert.AreEqual(user.LastLoginTime, actual.LastLoginTime); }
public void GivenUserIsConfiguredAsAdministrator_AndHasDataAdminRole_WhenIExecuteDataSelector_ThenDataRolesContainsAdministratorAndDataAdmin() { UserClientDataTable target = new UserClientDataTable(MockRequest, SecurityConfiguration); User user = new User { EmailAddress = "*****@*****.**", UserRoles = new List <UserRole> { new UserRole { Role = new Role { Name = SecurityRoles.DataAdmin } } } }; string[] expected = new[] { "Administrator", SecurityRoles.DataAdmin }; SecurityConfiguration.Expect(m => m.AdministratorEmailAddresses).Return(new string[] { user.EmailAddress }); dynamic actual = target.DataSelector.Compile().Invoke(user); CollectionAssert.AreEqual(expected, ((IEnumerable <string>)actual.Roles).ToList()); }