public async Task TestProjectFromEntityToDtoIgnoreQueryFiltersOk() { //SETUP var options = SqliteInMemory.CreateOptions <TestDbContext>(); using (var context = new TestDbContext(options)) { context.Database.EnsureCreated(); var author = new SoftDelEntity { SoftDeleted = true }; context.Add(author); context.SaveChanges(); } using (var context = new TestDbContext(options)) { var utData = context.SetupSingleDtoAndEntities <SoftDelEntityDto>(); var service = new CrudServicesAsync(context, utData.ConfigAndMapper); context.SoftDelEntities.Count().ShouldEqual(0); context.SoftDelEntities.IgnoreQueryFilters().Count().ShouldEqual(1); //ATTEMPT var dto = await service.ProjectFromEntityToDto <SoftDelEntity, SoftDelEntityDto>(x => x.IgnoreQueryFilters().Where(y => y.Id == 1)) .SingleAsync(); //VERIFY service.IsValid.ShouldBeTrue(service.GetAllErrors()); dto.Id.ShouldEqual(1); } }
public async Task TestProjectFromEntityToDtoOk() { //SETUP var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); context.SeedDatabaseFourBooks(); var utData = context.SetupSingleDtoAndEntities <BookTitle>(); var service = new CrudServicesAsync(context, utData.ConfigAndMapper); //ATTEMPT var dto = await service.ProjectFromEntityToDto <Book, BookTitle>(x => x.Where(y => y.BookId == 1)).SingleAsync(); //VERIFY service.IsValid.ShouldBeTrue(service.GetAllErrors()); dto.BookId.ShouldEqual(1); dto.Title.ShouldEqual("Refactoring"); } }