예제 #1
0
        public async Task GetAllAwardsShouldReturnZeroWhenAwardsAreDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var awards = new List <Award>();

            for (int i = 1; i <= 10; i++)
            {
                awards.Add(
                    new Award
                {
                    Name      = $"test{i}",
                    CreatedOn = DateTime.UtcNow,
                    IsDeleted = true,
                    DeletedOn = DateTime.UtcNow,
                });
            }

            await db.Awards.AddRangeAsync(awards);

            await db.SaveChangesAsync();

            var awardsService = new AwardsService(db);
            var result        = await awardsService.GetAllAwardsAsync <AwardTestModel>();

            Assert.Empty(result);
        }
예제 #2
0
        public async Task GetAllAwardsShouldReturnZeroWhenAwardsAreEmpty()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var awards = new List <Award>();

            var awardsService = new AwardsService(db);
            var result        = await awardsService.GetAllAwardsAsync <AwardTestModel>();

            Assert.Empty(result);
        }