Ejemplo n.º 1
0
        public async Task DeleteFailsWhenIdNotInDatabase()
        {
            AutoMapperInitializer.InitializeMapper();
            var context    = InMemoryDbContextInitializer.InitializeContext();
            var repository = new EfDeletableEntityRepository <FileExtension>(context);

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

            Assert.False(result);
        }
Ejemplo n.º 2
0
        public async Task DeleteMarksRecordAsDeleted()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.FileExtensions.AddAsync(new FileExtension { Id = 1, Name = "Extension", FileType = "File", IsDeleted = false });

            await context.SaveChangesAsync();

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

            var service = new FileExtensionsService(repository);

            var result = await service.DeleteAsync(1);

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

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