예제 #1
0
        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)));
        }
예제 #2
0
        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" });
            }
        }
예제 #3
0
        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" });
            }
        }
예제 #6
0
        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" });
            }
        }
예제 #7
0
        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" });
            }
        }