Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }