Exemplo n.º 1
0
        public async Task CheckGettingActiveAndExpiredCardsAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository          = new EfDeletableEntityRepository <Card>(db);
            var typeCardRespository = new EfDeletableEntityRepository <TypeCard>(db);

            var service = new CardsService(
                typeCardRespository,
                repository);

            var firstUser = new ApplicationUser()
            {
                Id = "1",
            };

            var secondUser = new ApplicationUser()
            {
                Id = "1",
            };

            var typeCard = new TypeCard()
            {
                Id    = "1",
                Price = 50,
                Name  = "Week",
            };

            await db.TypeCards.AddAsync(typeCard);

            await db.SaveChangesAsync();

            await service.CreateCardAsync(firstUser.Id, typeCard.Price);

            await service.CreateCardAsync(secondUser.Id, typeCard.Price);

            var activeCards = await service.GetActiveCardsAsync <TestCardModel>();

            var expiredCards = await service.GetExpiredCardsAsync <TestCardModel>();

            Assert.Equal(2, activeCards.Count());
            Assert.Empty(expiredCards);
        }