public void AddUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); //Act var id = Guid.NewGuid(); userService.AddUser(id, "*****@*****.**", "Password"); //Assert Assert.AreEqual(id, mockUserDAL.users.First().UserId); }
public void RegisterUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.Register(Guid.NewGuid(), "*****@*****.**", "Robert", "Hoi ik ben Robert"); //Assert Assert.AreEqual(1, mockUserDAL.users.Count); Assert.AreEqual("*****@*****.**", mockUserDAL.users[0].Email); Assert.AreEqual("Robert", mockUserDAL.users[0].DisplayName); Assert.AreEqual("Hoi ik ben Robert", mockUserDAL.users[0].Biography); }
public void CheckCredentialsFailureTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); mockUserDAL.users.Add(new Models.User { Email = "*****@*****.**" }); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.CheckCredentials("*****@*****.**", "*****@*****.**", "Password", "Password"); //Assert Assert.IsFalse(result); }
public void GetUserFailureTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); var id = Guid.NewGuid(); mockUserDAL.users.Add(new Models.User { Email = "*****@*****.**", UserId = id }); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.GetUser(Guid.NewGuid()); //Assert Assert.Null(result); }
public void AuthenticateFailureTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); var id = Guid.NewGuid(); User user = new User { UserId = id, Email = "*****@*****.**", Password = "******", Role = Roles.User }; mockUserDAL.users.Add(user); //Act string result = userService.Authenticate("*****@*****.**", "xxxxx"); //Assert Assert.Null(result); }
public void DeleteUserFailureTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); var id = Guid.NewGuid(); User user = new User { UserId = id, Email = "*****@*****.**", Password = "******", Role = Roles.User }; mockUserDAL.users.Add(user); //Act userService.DeleteUser(Guid.NewGuid()); //Assert Assert.AreEqual(1, mockUserDAL.users.Count()); }
public void DeleteUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); var id = Guid.NewGuid(); User user = new User { UserId = id, Email = "*****@*****.**", Password = "******", Role = Roles.User }; mockUserDAL.users.Add(user); //Act userService.DeleteUser(id); //Assert Assert.Null(mockUserDAL.users.FirstOrDefault(e => e.UserId == id)); }
public void GetUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); var id = Guid.NewGuid(); User user = new User { UserId = id, Email = "*****@*****.**", Password = "******", Role = Roles.User }; mockUserDAL.users.Add(user); //Act var result = userService.GetUser(id); //Assert Assert.AreEqual(id, result.UserId); }
public void GetUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); var id = Guid.NewGuid(); mockUserDAL.users.Add(new Models.User { Email = "*****@*****.**", UserId = id }); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.GetUser(id); //Assert Assert.NotNull(result); Assert.AreEqual("*****@*****.**", result.Email); Assert.AreEqual(id, result.UserId); }
public void ChangeUserNoChangeTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); UserService userService = new UserService(mockUserDAL, new MockCrypthographyService(), new MockJwtAuthenticationManager()); var id = Guid.NewGuid(); User user = new User { UserId = id, Email = "*****@*****.**", Password = "******", Role = Roles.User }; mockUserDAL.users.Add(user); //Act userService.ChangeUser(id, "*****@*****.**"); //Assert Assert.AreEqual("*****@*****.**", mockUserDAL.users.First().Email); Assert.AreEqual(id, mockUserDAL.users.First().UserId); }
public void DeleteUserSuccesTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); var id = Guid.NewGuid(); Models.User user = new Models.User { Email = "*****@*****.**", UserId = id }; mockUserDAL.users.Add(user); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.DeleteUser(user); //Assert Assert.True(result.Result); Assert.AreEqual(0, mockUserDAL.users.Count); }
public void UpdateUserFailureTest() { //Arrange MockUserDAL mockUserDAL = new MockUserDAL(); var id = Guid.NewGuid(); mockUserDAL.users.Add(new Models.User { Email = "*****@*****.**", UserId = id }); mockUserDAL.users.Add(new Models.User { Email = "*****@*****.**", UserId = Guid.NewGuid() }); Services.UserService userService = new Services.UserService(mockUserDAL, new MockMessagePublisher()); //Act var result = userService.UpdateUser(new Models.User { UserId = id, Email = "*****@*****.**" }); //Assert Assert.IsFalse(result.Result); }