コード例 #1
0
        public IActionResult ChangePromotion(int id)
        {
            Request.ThrowErrorIfNotLocal();

            var service    = new ChangePriceOfferService(_context);
            var priceOffer = service.GetOriginal(id);

            ViewData["BookTitle"] = service.OrgBook.Title;
            ViewData["OrgPrice"]  = service.OrgBook.Price < 0
                ? "Not currently for sale"
                : service.OrgBook.Price.ToString("c", new CultureInfo("en-US"));
            SetupTraceInfo();
            return(View(priceOffer));
        }
コード例 #2
0
        public void TestGetOriginal(int bookIndex, bool hasPromotion)
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <EfCoreContext>();

            using (var context = new EfCoreContext(options))
            {
                context.Database.EnsureCreated();
                var books = context.SeedDatabaseFourBooks();

                var service = new ChangePriceOfferService(context);

                //ATTEMPT
                var priceOffer = service.GetOriginal(books[bookIndex].BookId);

                //VERIFY
                (priceOffer.NewPrice != books[bookIndex].Price).ShouldEqual(hasPromotion);
            }
        }
コード例 #3
0
        public void AddRemovePriceOffer(int bookIndex, int numPriceOffers)
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <EfCoreContext>();

            using (var context = new EfCoreContext(options))
            {
                context.Database.EnsureCreated();
                var books = context.SeedDatabaseFourBooks();

                var service    = new ChangePriceOfferService(context);
                var priceOffer = service.GetOriginal(books[bookIndex].BookId);

                //ATTEMPT
                var error = service.AddRemovePriceOffer(priceOffer);

                //VERIFY
                context.PriceOffers.Count().ShouldEqual(numPriceOffers);
            }
        }