public void DeletedAppUserShoundNotExistInDatabase() { //Arrange NewAppUserVm appUserToAdd = new NewAppUserVm() { Id = 1, FirstName = "test", PositionId = 1 }; var options = new DbContextOptionsBuilder <Context>() .UseInMemoryDatabase("UsersDirectoryMVC") .Options; var config = new MapperConfiguration(c => { c.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); using (var context = new Context(options)) { //Act var appUserService = new AppUserService(mapper, new AppUserRepository(context)); var result = appUserService.AddAppUser(appUserToAdd); appUserService.DeleteAppUser(1); var deletedAppUser = appUserService.GetAppUserDetails(1); //Assert deletedAppUser.Should().BeNull(); } }
public void DeleteAppUserByNameFalse() { IAppUserService service = new AppUserService(); const string userName = "******"; const string falseName = "not docker"; bool creationBool = service.CreateAppUser(userName, Password, Salt); bool existBeforeDeletion = service.AppUserExist(userName); bool deletionBool = service.DeleteAppUser(falseName); Assert.True(creationBool); Assert.True(existBeforeDeletion); Assert.False(deletionBool); Assert.True(service.AppUserExist(userName)); //clean up todo delete when mock is working service.DeleteAppUser(userName); }
public void DeleteAppUserByIdFalse() { IAppUserService service = new AppUserService(); const string userName = "******"; const int falseId = -2; bool creationBool = service.CreateAppUser(userName, Password, Salt); int userId = service.GetAppUserId(userName); bool existBeforeDeletion = service.AppUserExist(userId); bool deletionBool = service.DeleteAppUser(falseId); Assert.True(creationBool); Assert.True(existBeforeDeletion); Assert.False(deletionBool); Assert.True(service.AppUserExist(userName)); Assert.True(service.AppUserExist(userId)); //clean up todo delete when mock is working service.DeleteAppUser(userName); }
public void CreateUserGetObject() { IAppUserService service = new AppUserService(); const string userName = "******"; AppUser user = service.CreateUser(userName, Password, Salt); Assert.Equal(userName, user.Username); //clean up todo delete when mock is working service.DeleteAppUser(user.Id); }
public void CreateAppUser() { IAppUserService service = new AppUserService(); const string userName = "******"; bool creationBool = service.CreateAppUser(userName, Password, Salt); int userId = service.GetAppUserId(userName); Assert.True(creationBool); Assert.Equal(userName, service.GetAppUserName(userId)); //clean up todo delete when mock is working service.DeleteAppUser(userId); }
public void DeleteAppUserByNameTrue() { IAppUserService service = new AppUserService(); const string userName = "******"; bool creationBool = service.CreateAppUser(userName, Password, Salt); bool existBeforeDeletion = service.AppUserExist(userName); bool deletionBool = service.DeleteAppUser(userName); Assert.True(creationBool); Assert.True(existBeforeDeletion); Assert.True(deletionBool); Assert.False(service.AppUserExist(userName)); }
public void UpdateAppUserNameValidUser() { IAppUserService service = new AppUserService(); const string userNameOne = "Ms. donald docker"; const string userNameTwo = "Ms. donald ducker"; bool creationBool = service.CreateAppUser(userNameOne, Password, Salt); int userIdOne = service.GetAppUserId(userNameOne); bool updateBool = service.UpdateAppUserName(userNameOne, userNameTwo); int userIdTwo = service.GetAppUserId(userNameTwo); Assert.True(creationBool); Assert.True(updateBool); Assert.Equal(userIdOne, userIdTwo); Assert.NotEqual(userNameOne, service.GetAppUserName(userIdOne)); Assert.Equal(userNameTwo, service.GetAppUserName(userIdOne)); //clean up todo delete when mock is working service.DeleteAppUser(userIdOne); service.DeleteAppUser(userIdTwo); }