コード例 #1
0
        public async Task DeleteFailsWhenIdNotInDatabase()
        {
            AutoMapperInitializer.InitializeMapper();
            var context    = InMemoryDbContextInitializer.InitializeContext();
            var repository = new EfDeletableEntityRepository <JobLevel>(context);

            var service = new JobLevelsService(repository);
            var result  = await service.DeleteAsync(100);

            Assert.False(result);
        }
コード例 #2
0
        public async Task DeleteMarksRecordAsDeleted()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobLevels.AddAsync(new JobLevel { Id = 1, Name = "Sector", IsDeleted = false });

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobLevel>(context);

            var service = new JobLevelsService(repository);

            var result = await service.DeleteAsync(1);

            var dbRecord = await context.JobLevels.FindAsync(1);

            Assert.True(result);
            Assert.True(dbRecord.IsDeleted);
            Assert.NotNull(dbRecord.DeletedOn);
            Assert.Equal(1, context.JobLevels.IgnoreQueryFilters().Count());
        }