public JsonResult GetFilterSearchContent(SortFilterPageOptionsDto options) { var bookFilterDropdown = new BookFilterDropdownService(dataContext); var dropDownValues = bookFilterDropdown.GetFilterDropDownValues(options.BooksFilterBy).ToArray(); return(Json(new TraceIndentGeneric <IEnumerable <DropdownTuple> >(HttpContext.TraceIdentifier, dropDownValues))); }
public void DropdownByDateExcludeBooksLaterThanCurrentTimeButInYear() { //SETUP if (DateTime.Today.AddDays(1).Year != DateTime.Today.Year) { throw new Exception("This unit test will fail if you run it on the last day of the year!"); } var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); var oldBook = new Book { PublishedOn = new DateTime(2000, 1, 1) }; var futureBookThisYear = new Book { PublishedOn = DateTime.UtcNow.Date.AddDays(1) }; context.Books.AddRange(oldBook, futureBookThisYear); context.SaveChanges(); var service = new BookFilterDropdownService(context); //ATTEMPT var dropDown = service.GetFilterDropDownValues(BooksFilterBy.ByPublicationYear); //VERIFY dropDown.Select(x => x.Value).ToArray().ShouldEqual(new[] { BookListDtoFilter.AllBooksNotPublishedString, "2000" }); } }
public JsonResult GetFilterSearchContent (SortFilterPageOptions options) { var service = new BookFilterDropdownService(new EfCoreContext()); return(Json(service.GetFilterDropDownValues( options.FilterBy), JsonRequestBehavior.AllowGet)); }
public JsonResult GetFilterSearchContent(SortFilterPageOptions options) { var service = new BookFilterDropdownService(_context); var traceIdent = HttpContext.TraceIdentifier; //This makes the logging display work return(Json( new TraceIndentGeneric <IEnumerable <DropdownTuple> >( traceIdent, service.GetFilterDropDownValues( options.FilterBy)))); }
public void DropdownByTag() { //SETUP var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); context.SeedDatabaseFourBooks(); var service = new BookFilterDropdownService(context); //ATTEMPT var dropDown = service.GetFilterDropDownValues(BooksFilterBy.ByTags); //VERIFY dropDown.Select(x => x.Value).ToArray().ShouldEqual( new[] { "Refactoring", "Editor's Choice", "Architecture", "Quantum Entanglement" }); } }
public void DropdownByDate() { //SETUP const int numBooks = 5; var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); context.Books.AddRange(EfTestData.CreateDummyBooks(numBooks, true)); context.SaveChanges(); var service = new BookFilterDropdownService(context); //ATTEMPT var dropDown = service.GetFilterDropDownValues(BooksFilterBy.ByPublicationYear); //VERIFY dropDown.Select(x => x.Value).ToArray().ShouldEqual(new[] { "2014", "2013", "2012", "2011", "2010" }); } }
public void DropdownByDate() { //SETUP var inMemDb = new SqliteInMemory(); const int numBooks = 5; using (var db = inMemDb.GetContextWithSetup()) { db.Books.AddRange(EfTestData.CreateDummyBooks(numBooks, true)); db.SaveChanges(); var service = new BookFilterDropdownService(db); //ATTEMPT var dropDown = service.GetFilterDropDownValues(BooksFilterBy.ByPublicationYear); //VERIFY dropDown.Select(x => x.Value).ToArray().ShouldEqual(new [] { "2014", "2013", "2012", "2011", "2010" }); } }