public void When_GetUser_is_called_with_an_Id_and_there_is_no_User_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown() { var users = UserCreator.CreateCollection(); var userId = Guid.NewGuid(); BandCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); BandCatalog.Replay(); Repository.GetUser(userId); }
public void When_GetUserByLoginName_is_called_with_a_valid_loginName_and_GetUsersByLoginName_on_the_AppRepository_returns_multiple_Users_then_an_InvalidOperationException_is_thrown() { var users = UserCreator.CreateCollection(); var user = users.ElementAt(2); var loginName = user.Login.LoginName; AppRepository .Expect(repository => repository.GetUsersByLoginName(loginName)) .Return(new List <User> { user, user }) .Repeat.Once(); AppRepository.Replay(); Process.GetUserByLoginName(loginName); }
public void When_GetUsersByEmailAddress_is_called_with_an_invalid_emailAddress_then_no_Users_with_that_emailAddress_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); const string emailAddress = "*****@*****.**"; AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetUsersByEmailAddress(emailAddress); Assert.IsNotNull(result); Assert.AreEqual(0, result.Count()); AppCatalog.VerifyAllExpectations(); }
public void When_GetUsersByLoginName_is_called_with_an_invalid_loginName_then_no_Users_with_that_loginName_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); const string loginName = "Invalid loginName"; AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetUsersByLoginName(loginName); Assert.IsNotNull(result); Assert.AreEqual(0, result.Count()); AppCatalog.VerifyAllExpectations(); }
public void When_GetUsersByLoginAccount_is_called_with_an_invalid_id_then_no_Users_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); var id = Guid.NewGuid(); AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetUsersByLoginAccount(id); Assert.IsNotNull(result); Assert.AreEqual(0, result.Count()); AppCatalog.VerifyAllExpectations(); }
public void When_GetAllUsers_is_called_then_all_Users_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetAllUsers(); Assert.IsNotNull(result); Assert.AreEqual(users.Count(), result.Count()); Assert.AreEqual(users, result); AppCatalog.VerifyAllExpectations(); }
public void When_GetUser_is_called_with_an_Id_then_the_User_with_the_corresponding_Id_is_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); var userId = users.ElementAt(2).Id; BandCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); BandCatalog.Replay(); var user = Repository.GetUser(userId); Assert.IsNotNull(user); Assert.AreEqual(userId, user.Id); BandCatalog.VerifyAllExpectations(); }
public void When_GetUsersByEmailAddress_is_called_with_a_emailAddress_then_all_Users_with_that_emailAddress_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); var emailAddress = users.ElementAt(2).Login.EmailAddress; AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetUsersByEmailAddress(emailAddress); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual(emailAddress, result.First().Login.EmailAddress); AppCatalog.VerifyAllExpectations(); }
public void When_GetUsersByLoginAccount_is_called_with_a_valid_id_then_all_Users_with_that_LoginAccount_are_retrieved_from_the_collection() { var users = UserCreator.CreateCollection(); var id = users.ElementAt(2).Login.Id; AppCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); AppCatalog.Replay(); var result = Repository.GetUsersByLoginAccount(id); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual(id, result.First().Login.Id); AppCatalog.VerifyAllExpectations(); }
public void When_GetUserByLoginName_is_called_with_a_valid_loginName_then_GetUsersByLoginName_on_the_AppRepository_is_called_with_that_LoginName() { var users = UserCreator.CreateCollection(); var user = users.ElementAt(2); var loginName = user.Login.LoginName; AppRepository .Expect(repository => repository.GetUsersByLoginName(loginName)) .Return(new List <User> { user }) .Repeat.Once(); AppRepository.Replay(); var result = Process.GetUserByLoginName(loginName); Assert.AreEqual(loginName, result.Login.LoginName); AppRepository.VerifyAllExpectations(); }
public void When_GetUserByLoginAccount_is_called_with_a_valid_id_then_GetUsersByLoginAccount_on_the_AppRepository_is_called_with_that_id() { var users = UserCreator.CreateCollection(); var user = users.ElementAt(2); var id = user.Login.Id; AppRepository .Expect(repository => repository.GetUsersByLoginAccount(id)) .Return(new List <User> { user }) .Repeat.Once(); AppRepository.Replay(); var result = Process.GetUserByLoginAccount(id); Assert.AreEqual(id, result.Login.Id); AppRepository.VerifyAllExpectations(); }