public void CreateAUserWithNullsDoesNotGetCreated(string user, string email, string password) { var mock = new Mock <IUserRepository>(); var postModel = new PostUserModel { UserName = user, EmailAddress = email, Active = true, PassWord = password }; var service = new UsersLogic(mock.Object); Assert.Throws <ArgumentException>(() => service.CreateANewUser(postModel)); }
public void CreateANewUserWithAllFieldsGetsAdded() { var mock = new Mock <IUserRepository>(); var username = "******"; var password = "******"; var email = "*****@*****.**"; var postModel = new PostUserModel { UserName = username, EmailAddress = email, Active = true, PassWord = password }; var service = new UsersLogic(mock.Object); service.CreateANewUser(postModel); mock.Verify(x => x.Add(It.IsAny <UserModel>()), Times.Exactly(1)); }
public void CreateANewUserWithEmailThatDoesExistThrowsArgumentException() { var mock = new Mock <IUserRepository>(); var username = "******"; var password = "******"; var email = "*****@*****.**"; var postModel = new PostUserModel { UserName = username, EmailAddress = email, Active = true, PassWord = password }; mock.Setup(e => e.CheckIfEmailExists(email)).Returns(true); var service = new UsersLogic(mock.Object); Assert.Throws <ArgumentException>(() => service.CreateANewUser(postModel)); }
public void CreateANewEmailWithUserThatDoesNotExistPasses() { var mock = new Mock <IUserRepository>(); var username = "******"; var password = "******"; var email = "*****@*****.**"; var postModel = new PostUserModel { UserName = username, EmailAddress = email, Active = true, PassWord = password }; mock.Setup(e => e.CheckIfEmailExists(email)).Returns(false); var service = new UsersLogic(mock.Object); service.CreateANewUser(postModel); mock.Verify(x => x.Add(It.IsAny <UserModel>()), Times.Exactly(1)); }