Example #1
0
        public async void IsActiveAsync_ThrowsNotFound_OnNonExistent()
        {
            //Arrange
            var contextOptions = InMemoryUtils.ProduceFreshDbContextOptions();
            var oldModel       = ResourceUtils.TestSet.First();

            using (var context = new ApplicationDbContext(contextOptions))
            {
                context.Resources.Add(oldModel);
                context.SaveChanges();
            }
            var newModel = ResourceUtils.TestSet.Last();

            using (var context = new ApplicationDbContext(contextOptions))
            {
                IActEntityRepository <Resource, int, ApplicationUser, string> repo = new ResourcesRepository(context);

                //Assert-Act
                await Assert.ThrowsAsync <CurrentEntryNotFoundException>(() => repo.IsActiveAsync(ResourceUtils.NonExistentId));
            }
        }
Example #2
0
        public async void IsActiveAsync_ReturnsCorrectBool(int id, bool expected)
        {
            //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.IsActiveAsync(id);

                //Assert
                Assert.IsAssignableFrom <bool>(result);
                Assert.Equal(expected, result);
            }
        }