public async Task SetIsDeletedToTrue_WhenValidIdIsPassed() { var userStoreMock = new Mock <IUserStore <User> >(); var userManager = new UserManager <User>(userStoreMock.Object, null, null, null, null, null, null, null, null); var contextOptions = new DbContextOptionsBuilder <BedeSlotsDbContext>() .UseInMemoryDatabase(databaseName: "SetIsDeletedToTrue_WhenValidIdIsPassed") .UseInternalServiceProvider(serviceProvider).Options; var user = new User(); using (var bedeSlotsContext = new BedeSlotsDbContext(contextOptions)) { bedeSlotsContext.Users.Add(user); bedeSlotsContext.SaveChanges(); } using (var bedeSlotsContext = new BedeSlotsDbContext(contextOptions)) { var sut = new Data.UserService(bedeSlotsContext, userManager); var result = await sut.DeleteUserAsync(user.Id); Assert.IsTrue(result.IsDeleted); } }
public async Task ThrowServiceException_WhenNullParameterIsPassed() { var userStoreMock = new Mock <IUserStore <User> >(); var userManager = new UserManager <User>(userStoreMock.Object, null, null, null, null, null, null, null, null); var contextOptions = new DbContextOptionsBuilder <BedeSlotsDbContext>() .UseInMemoryDatabase(databaseName: "ThrowServiceException_WhenNullParameterIsPassed") .UseInternalServiceProvider(serviceProvider).Options; using (var bedeSlotsContext = new BedeSlotsDbContext(contextOptions)) { var sut = new Data.UserService(bedeSlotsContext, userManager); await Assert.ThrowsExceptionAsync <ServiceException>(async() => await sut.DeleteUserAsync(null)); } }