public void GetNameShouldReturnUserName() { var mock = new UserManagerMock(); var result = mock.UserManager.GetName(MembershipTestData.AdminId); Assert.AreEqual(MembershipTestData.Administrator.Name, result); }
public void GetByEmailShouldReturnCorrectUser() { var mock = new UserManagerMock(); var result = mock.UserManager.Get(MembershipTestData.Administrator.Email); Assert.IsNotNull(result); Assert.AreEqual(MembershipTestData.AdminId, result.Id); }
public void QueryUsersForMainGroupShouldReturnAllUsersForMainGroup() { var mock = new UserManagerMock(); var result = mock.UserManager.Query().Count(); Assert.AreEqual(2, result); }
public void GetIdShouldReturnUserId() { var mock = new UserManagerMock(); var result = mock.UserManager.GetId(MembershipTestData.Administrator.Email); Assert.AreEqual(MembershipTestData.AdminId, result); }
public void GetByIdShouldReturnCorrectUser() { var mock = new UserManagerMock(); var result = mock.UserManager.Get(MembershipTestData.AdminId); Assert.IsNotNull(result); Assert.AreEqual(MembershipTestData.AdminId, result.Id); }
public void CreateUserWithoutPreferredCultureShouldSetPreferredCultureToDefault() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", null, "TestTest!", false, false, It.IsAny <string>()); Assert.IsNotNull(result); Assert.AreEqual("en", result.PreferredCulture); }
public void GetNumberOfOnlineUsersShouldReturnNumberOfUsersOnlineForGroup() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(MembershipTestData.DivingGroupId); mock.UserManager.UpdateLoggedInUser(MembershipTestData.DivingManager); var after = mock.UserManager.GetNumberOfUsersOnline(MembershipTestData.DivingGroupId); Assert.IsTrue(after == before + 1); }
public void UpdateLoggedInUsersShouldUpdateLoggedInUserCount() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(); mock.UserManager.UpdateLoggedInUser(MembershipTestData.Administrator); var after = mock.UserManager.GetNumberOfUsersOnline(); Assert.IsTrue(after == before + 1); }
public void RemoveLoggedInUsersShouldUpdateLoggedInUserCount() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(); mock.UserManager.UpdateLoggedInUser(MembershipTestData.KarateManager); mock.UserManager.RemoveLoggedInUser(MembershipTestData.KarateManager.Id); var after = mock.UserManager.GetNumberOfUsersOnline(); Assert.IsTrue(before == after); }
public void GetSessionShouldRestoreSavedSessionValues() { var environmentMock = new Mock <IEnvironment>(); StrixPlatform.Environment = environmentMock.Object; var mock = new UserManagerMock(); mock.UserManager.GetSession(MembershipTestData.Administrator.Email); environmentMock.Verify(e => e.StoreInSession("CurrentGroupId", It.IsAny <object>()), Times.Once()); }
public void GetNumberOfOnlineUsersShouldReturnNumberOfUsersOnlineForGroup() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(MembershipTestData.DivingGroupId); mock.UserManager.UpdateLoggedInUser(MembershipTestData.DivingManager); var after = mock.UserManager.GetNumberOfUsersOnline(MembershipTestData.DivingGroupId); Assert.IsTrue(after == before + 1); }
public void UpdateLoggedInUsersShouldUpdateLoggedInUserCount() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(); mock.UserManager.UpdateLoggedInUser(MembershipTestData.Administrator); var after = mock.UserManager.GetNumberOfUsersOnline(); Assert.IsTrue(after == before + 1); }
public void UpdateUserWithNewValidEmailShouldUpdateUser() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); var result = mock.UserManager.Update(MembershipTestData.AdminId, "Test", "Test", "en"); Assert.AreEqual("Test", result.Name); Assert.AreEqual("Test", result.Email); Assert.AreEqual("en", result.PreferredCulture); }
public void DeleteUserShouldDeleteUserRolesProfileValuesAndUser() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); mock.DataSourceMock.RegisterData(MembershipTestData.UsersInRoles); var group = mock.DataSourceMock.DataList <Group>().First(u => u.Id == MembershipTestData.DivingGroupId); mock.UserManager.Delete(MembershipTestData.DivingManagerId); mock.DataSourceMock.Mock.Verify(d => d.Delete(It.IsAny <User>()), Times.Once()); }
public void DeleteUserShouldUpdateGroupUserCount() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); mock.DataSourceMock.RegisterData(MembershipTestData.UsersInRoles); var role = mock.DataSourceMock.DataList <UserInRole>().Where(u => u.UserId == MembershipTestData.DivingEditorId && u.GroupRole.Role.Name == MembershipTestData.EditorRoleName).Select(r => r.GroupRole).First(); mock.UserManager.Delete(MembershipTestData.DivingEditorId); Assert.AreEqual(1, role.CurrentNumberOfUsers); }
public void RemoveLoggedInUsersShouldUpdateLoggedInUserCount() { var mock = new UserManagerMock(); var before = mock.UserManager.GetNumberOfUsersOnline(); mock.UserManager.UpdateLoggedInUser(MembershipTestData.KarateManager); mock.UserManager.RemoveLoggedInUser(MembershipTestData.KarateManager.Id); var after = mock.UserManager.GetNumberOfUsersOnline(); Assert.IsTrue(before == after); }
public void SaveSessionShouldSaveSessionValues() { var mock = new UserManagerMock(); var dict = new Dictionary <string, object>(); dict.Add("CurrentGroupId", MembershipTestData.MainGroupId); var environmentMock = new Mock <IEnvironment>(); environmentMock.Setup(e => e.GetSessionDictionary()).Returns(dict); StrixPlatform.Environment = environmentMock.Object; mock.UserManager.SaveSession(MembershipTestData.AdminId, null); mock.DataSourceMock.Mock.Verify(m => m.Save(It.IsAny <UserSessionStorage>()), Times.Once()); }
public void CreateUserWithAllFieldsSpecifiedShouldCreateValidUser() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "TestTest!", false, false, It.IsAny <string>()); Assert.IsNotNull(result); Assert.AreEqual("Test", result.Name); Assert.AreEqual("Test", result.Email); Assert.AreEqual("en", result.PreferredCulture); Assert.IsNull(result.DateAcceptedTerms); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny <User>()), Times.Once()); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny <UserSecurity>()), Times.Once()); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny <UserSessionStorage>()), Times.Once()); }
public void DeleteUserShouldDeleteUserRolesProfileValuesAndUser() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); mock.DataSourceMock.RegisterData(MembershipTestData.UsersInRoles); var group = mock.DataSourceMock.DataList<Group>().First(u => u.Id == MembershipTestData.DivingGroupId); mock.UserManager.Delete(MembershipTestData.DivingManagerId); mock.DataSourceMock.Mock.Verify(d => d.Delete(It.IsAny<User>()), Times.Once()); }
public void CreateUserWithAPasswordWithNotEnoughNonAlphanumericCharactersShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "TestTest2", false, false, It.IsAny<string>()); }
public void GetSessionShouldRestoreSavedSessionValues() { var environmentMock = new Mock<IEnvironment>(); StrixPlatform.Environment = environmentMock.Object; var mock = new UserManagerMock(); mock.UserManager.GetSession(MembershipTestData.Administrator.Email); environmentMock.Verify(e => e.StoreInSession("CurrentGroupId", It.IsAny<object>()), Times.Once()); }
public void DeleteUserShouldUpdateGroupUserCount() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); mock.DataSourceMock.RegisterData(MembershipTestData.UsersInRoles); var role = mock.DataSourceMock.DataList<UserInRole>().Where(u => u.UserId == MembershipTestData.DivingEditorId && u.GroupRole.Role.Name == MembershipTestData.EditorRoleName).Select(r => r.GroupRole).First(); mock.UserManager.Delete(MembershipTestData.DivingEditorId); Assert.AreEqual(1, role.CurrentNumberOfUsers); }
public void CreateUserWithoutPreferredCultureShouldSetPreferredCultureToDefault() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", null, "TestTest!", false, false, It.IsAny<string>()); Assert.IsNotNull(result); Assert.AreEqual("en", result.PreferredCulture); }
public void SaveSessionShouldSaveSessionValues() { var mock = new UserManagerMock(); var dict = new Dictionary<string, object>(); dict.Add("CurrentGroupId", MembershipTestData.MainGroupId); var environmentMock = new Mock<IEnvironment>(); environmentMock.Setup(e => e.GetSessionDictionary()).Returns(dict); StrixPlatform.Environment = environmentMock.Object; mock.UserManager.SaveSession(MembershipTestData.AdminId, null); mock.DataSourceMock.Mock.Verify(m => m.Save(It.IsAny<UserSessionStorage>()), Times.Once()); }
public void CreateUserWithTooShortAPasswordShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "test", false, false, It.IsAny <string>()); }
public void GetEmailShouldReturnUserEmail() { var mock = new UserManagerMock(); var result = mock.UserManager.GetEmail(MembershipTestData.AdminId); Assert.AreEqual(MembershipTestData.Administrator.Email, result); }
public void CreateUserWithAllFieldsSpecifiedShouldCreateValidUser() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "TestTest!", false, false, It.IsAny<string>()); Assert.IsNotNull(result); Assert.AreEqual("Test", result.Name); Assert.AreEqual("Test", result.Email); Assert.AreEqual("en", result.PreferredCulture); Assert.IsNull(result.DateAcceptedTerms); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny<User>()), Times.Once()); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny<UserSecurity>()), Times.Once()); mock.DataSourceMock.Mock.Verify(d => d.Save(It.IsAny<UserSessionStorage>()), Times.Once()); }
public void CreateUserWithExistingEmailShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "*****@*****.**", "en", "TestTest!", false, false, It.IsAny <string>()); }
public void CreateUserWithAPasswordWithNotEnoughNonAlphanumericCharactersShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "TestTest2", false, false, It.IsAny <string>()); }
public void UpdateUserWithNewValidEmailShouldUpdateUser() { var mock = new UserManagerMock(); mock.DataSourceMock.RegisterData(MembershipTestData.Groups); var result = mock.UserManager.Update(MembershipTestData.AdminId, "Test", "Test", "en"); Assert.AreEqual("Test", result.Name); Assert.AreEqual("Test", result.Email); Assert.AreEqual("en", result.PreferredCulture); }
public void CreateUserWithExistingEmailShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "*****@*****.**", "en", "TestTest!", false, false, It.IsAny<string>()); }
public void QueryUsersForMainGroupShouldReturnAllUsersForMainGroup() { var mock = new UserManagerMock(); var result = mock.UserManager.Query().Count(); Assert.AreEqual(2, result); }
public void CreateUserWithTooShortAPasswordShouldThrowException() { var mock = new UserManagerMock(); var result = mock.UserManager.Create("Test", "Test", "en", "test", false, false, It.IsAny<string>()); }