public async Task ReturnUsersCurrency_WhenValidParameterIsPassed() { 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: "ReturnUsersCurrency_WhenValidParameterIsPassed") .UseInternalServiceProvider(serviceProvider).Options; var user = new User() { Currency = Currency.BGN }; 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.GetUserCurrencyByIdAsync(user.Id); Assert.IsTrue(result == Currency.BGN); } }
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.GetUserCurrencyByIdAsync(null)); } }