public async Task GetCardViewModelAsyncShouldReturnNull(string userId) { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var db = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Card>(db); var service = new CardsService(repository, this.qrcodeService.Object, this.notificationsService.Object); var result = await service.GetCardViewModelAsync <TestCardModel>(userId); Assert.Null(result); }
public async Task GetCardViewModelAsyncShouldReturnCorrectModel() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var db = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Card>(db); var user = new ApplicationUser(); await repository.AddAsync(new Card() { User = user, UserId = user.Id, }); await repository.SaveChangesAsync(); var service = new CardsService(repository, this.qrcodeService.Object, this.notificationsService.Object); var result = await service.GetCardViewModelAsync <TestCardModel>(user.Id); Assert.Equal(user.CardId, result.Id); Assert.Equal(0, result.Visits); }