public void BookDataService_CalculateTotalCost_Verify()
        {
            Mock <DbBookStoreContext> mockdb = new Mock <DbBookStoreContext>();

            var usersMockBook = UnitTestDBset.CreateDbSetMock(UnitTestDBset.BookList());

            mockdb.Setup(x => x.Book).Returns(usersMockBook.Object);

            var usersMockCategory = UnitTestDBset.CreateDbSetMock(UnitTestDBset.CategoryList());

            mockdb.Setup(x => x.Category).Returns(usersMockCategory.Object);

            var usersMockPromo = UnitTestDBset.CreateDbSetMock(UnitTestDBset.PromoList());

            mockdb.Setup(x => x.Promo).Returns(usersMockPromo.Object);

            //==========================================================
            IBook testbook    = UnitTestDBset.BookList()[3];
            var   bookservice = new BookDataService(mockdb.Object);
            var   resultcost  = bookservice.CalculateTotalCost().Result;

            IOrderCost testordercost = new OrderCost
            {
                Subtotal  = 57.74,
                Totaltax  = 5.77,
                TotalCost = 63.51
            };

            Assert.AreEqual(testordercost.Subtotal, resultcost.Subtotal);
            Assert.AreEqual(testordercost.Totaltax, resultcost.Totaltax);
            Assert.AreEqual(testordercost.TotalCost, resultcost.TotalCost);
        }
Ejemplo n.º 2
0
        protected async Task HandleValidSubmit()
        {
            if (Book.Id == 0)
            {
                Book book = await BookDataService.Add(Book);

                if (book != null)
                {
                    StatusClass = "alert-success";
                    Message     = "New employee added successfully.";
                    Saved       = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new employee. Please try again.";
                    Saved       = false;
                }
            }
            else
            {
                //HttpResponseMessage response = await HttpClient.PutAsJsonAsync($"api/books/{BookId}", Book);

                await BookDataService.Update(Book);

                StatusClass = "alert-success";
                Message     = "Employee updated successfully.";
                Saved       = true;
            }
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            var bookDataService = new BookDataService(configuration.GetConnectionString("SavaBookTask"));
            var books           = bookDataService.GetBooks();

            return(View(books));
        }
Ejemplo n.º 4
0
        protected async Task SaveBook()
        {
            book.PictureUrl = $"/images/books/Book{_random.Next(1, 10)}.jpg";

            await BookDataService.AddBook(book);

            NavigationManager.NavigateTo("bookslist");
        }
Ejemplo n.º 5
0
        public void ValidCourseId_ShouldHaveBooks()
        {
            var sut = new BookDataService();

            var result = sut.GenerateBooksForCourse(3);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count() > 1);
        }
Ejemplo n.º 6
0
        protected override async Task OnInitializedAsync()
        {
            Saved = false;

            int.TryParse(BookId, out int bookId);

            if (bookId == 0)
            {
                Book = new Book {
                    Title = "Default Title", Author = "Default Author"
                };
            }
            else
            {
                Book = await BookDataService.GetById(bookId);
            }
        }
        public void BookDataService_GetBookOrderList_NotNull()
        {
            Mock <DbBookStoreContext> mockdb = new Mock <DbBookStoreContext>();

            var usersMockBook = UnitTestDBset.CreateDbSetMock(UnitTestDBset.BookList());

            mockdb.Setup(x => x.Book).Returns(usersMockBook.Object);

            var usersMockCategory = UnitTestDBset.CreateDbSetMock(UnitTestDBset.CategoryList());

            mockdb.Setup(x => x.Category).Returns(usersMockCategory.Object);

            var usersMockPromo = UnitTestDBset.CreateDbSetMock(UnitTestDBset.PromoList());

            mockdb.Setup(x => x.Promo).Returns(usersMockPromo.Object);

            //==========================================================
            var bookservice = new BookDataService(mockdb.Object);
            var resultlist  = bookservice.GetBookOrderList().Result;

            Assert.AreEqual(UnitTestDBset.BookList().Count, resultlist.Count);
        }
        public void BookDataService_GetBookOnSale_With_Discount()
        {
            Mock <DbBookStoreContext> mockdb = new Mock <DbBookStoreContext>();

            var usersMockBook = UnitTestDBset.CreateDbSetMock(UnitTestDBset.BookList());

            mockdb.Setup(x => x.Book).Returns(usersMockBook.Object);

            var usersMockCategory = UnitTestDBset.CreateDbSetMock(UnitTestDBset.CategoryList());

            mockdb.Setup(x => x.Category).Returns(usersMockCategory.Object);

            var usersMockPromo = UnitTestDBset.CreateDbSetMock(UnitTestDBset.PromoList());

            mockdb.Setup(x => x.Promo).Returns(usersMockPromo.Object);

            //==========================================================
            IBook testbook    = UnitTestDBset.BookList()[3];
            var   bookservice = new BookDataService(mockdb.Object);
            var   resultlist  = bookservice.GetBookOnSale(testbook).Result;

            Assert.IsNotNull(resultlist.DiscountedPrice());
        }
Ejemplo n.º 9
0
 protected override async Task OnInitializedAsync()
 {
     Books = await BookDataService.GetAllBooks();
 }
Ejemplo n.º 10
0
 protected async void DeleteBook()
 {
     await BookDataService.Delete(Book.Id);
 }
Ejemplo n.º 11
0
 public BookStore()
 {
     _dbBookManager = new BookDataService();
 }
Ejemplo n.º 12
0
        public ActionResult Books()
        {
            BookDataService dataService = new BookDataService(Request.MapPath(BookDataService.DataUri));

            return(View("Book", new BookListViewModel(dataService.Get(), dataService.GetAuthors())));
        }
 public BookProcessorController()
 {
     bookDataService = new BookDataService();
 }