Ejemplo n.º 1
0
        public async void CountAsync_ReturnsCorrectCount()
        {
            //Arrange
            var options = InMemoryUtils.ProduceFreshDbContextOptions();

            using (var context = new ApplicationDbContext(options))
            {
                context.Resources.AddRange(ResourceUtils.TestSet);
                context.SaveChanges();
            }

            //Act
            using (var context = new ApplicationDbContext(options))
            {
                IActEntityRepository <Resource, int, ApplicationUser, string> repo = new ResourcesRepository(context);
                var result = await repo.CountActiveAsync();

                //Assert
                Assert.IsAssignableFrom <int>(result);
                Assert.Equal(ResourceUtils.TestSet.Count(r => r.IsActive == true), result);
            }
        }