public async Task ThrowExeptionWhenBookLendingIsNullRenewBook_Test() { var isbn = "TestIsbn"; var username = "******"; var days = 5; var renewBookDto = new RenewBookDto(); var lendDto = new BaseTitleDto(); var options = TestUtilities.GetOptions(nameof(ThrowExeptionWhenBookLendingIsNullRenewBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var book = await actContext.Books.AddAsync(new Book { ISBN = isbn }); var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); renewBookDto.BookId = days; renewBookDto.BookId = book.Entity.Id; renewBookDto.UserId = user.Entity.Id; } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.RenewBookAsync(renewBookDto); var actuaDays = assertContext.BookLendings.Select(book => book.Date); } }
public async Task LendBook_Test() { var title = "TestTitle"; var username = "******"; var lendBookDto = new BaseTitleDto(); var options = TestUtilities.GetOptions(nameof(LendBook_Test)); using (var actContext = new LibrarySystemContext(options)) { await actContext.Books.AddAsync(new Book { Title = title }); var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); lendBookDto.Title = title; lendBookDto.UserId = user.Entity.Id; } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.LendBookAsync(lendBookDto); Assert.AreEqual(1, assertContext.BookLendings.Count()); } }
public async Task ReturnFalseWhenBookIsNullReserveBook_Test() { string title = null; var username = "******"; var reserveBookDto = new BaseTitleDto(); var options = TestUtilities.GetOptions(nameof(ReturnFalseWhenBookIsNullReserveBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); reserveBookDto.Title = title; reserveBookDto.UserId = user.Entity.Id; } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); var bookReserve = await sut.ReserveBookAsync(reserveBookDto); Assert.IsFalse(bookReserve); } }
public async Task RemoveBook_Test() { var isbn = "1234567890"; var options = TestUtilities.GetOptions(nameof(ThrowBookException_WhenPublishDateIsIncorrect_Test)); using (var actContext = new LibrarySystemContext(options)) { var book = await actContext.Books.AddAsync(new Book { ISBN = isbn }); await actContext.SaveChangesAsync(); } var removeBookDto = new RemoveBookDto { ISBN = isbn }; using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.RemoveBookAsync(removeBookDto); Assert.AreEqual(0, assertContext.Books.Count()); } }
public async Task ThrowExeptionWhenUserNoHAveBookForReturnReturnBook_Test() { var isbn = "TestIsbn"; var username = "******"; var reviewDto = new ReviewDto(); var options = TestUtilities.GetOptions(nameof(ThrowExeptionWhenUserNoHAveBookForReturnReturnBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var book = await actContext.Books.AddAsync(new Book { ISBN = isbn }); var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); reviewDto.ISBN = book.Entity.ISBN; reviewDto.BookId = book.Entity.Id; reviewDto.UserId = user.Entity.Id; } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.ReturnBookAsync(reviewDto); } }
public async Task ThrowExeptionWhenBookIdIsNullReturnBook_Test() { var title = "TestTitle"; var username = "******"; var reviewDto = new ReviewDto(); var lendDto = new BaseTitleDto(); var options = TestUtilities.GetOptions(nameof(ThrowExeptionWhenBookIdIsNullReturnBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var book = await actContext.Books.AddAsync(new Book { Title = title }); var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); reviewDto.UserId = user.Entity.Id; lendDto.UserId = user.Entity.Id; var bookLending = new BookWebService(actContext); await bookLending.LendBookAsync(lendDto); } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.ReturnBookAsync(reviewDto); } }
public async Task ThrowBookExeptionInvalidInputAddBook_Test(string isbn, string title) { var pages = 300; var subject = "TestSubject"; var publishers = "TestPublishers"; var publishDate = "TestPublishDate"; var author = "TestAuthor"; var picture = "TestPicture"; var options = TestUtilities.GetOptions(nameof(ThrowBookExeptionInvalidInputAddBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var sut = new BookWebService(actContext); var book = await sut.CreateBookAsync(isbn, title, pages, subject, publishers, publishDate, author, picture); } }
private async Task DeleteBook() { var confirmParams = new ModalParameters(); confirmParams.Add(nameof(Confirm.ConfirmationMessage), $"آیا از حذف کتاب {BookDto.Title} مطمئن میباشید؟"); var confirmModal = ModalService.Show <Confirm>("تایید حذف", confirmParams); var result = await confirmModal.Result; if (!result.Cancelled && (bool)result.Data) { await BookWebService.DeleteBook(BookDto.Id); ToastService.ShowSuccess("حذف کتاب با موفقیت انجام شد"); await StateChangeRequest.InvokeAsync(); } }
public async Task ThrowBookException_WhenPublishDateIsIncorrect_Test() { var publishDate = "TestDate"; var options = TestUtilities.GetOptions(nameof(ThrowBookException_WhenPublishDateIsIncorrect_Test)); using (var actContext = new LibrarySystemContext(options)) { await actContext.Books.AddAsync(new Book { PublishDate = "Other Date" }); await actContext.SaveChangesAsync(); } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); var bookSearch = await sut.SearchBookAsync(null, null, null, publishDate); } }
public async Task SearchBookByPublishDate_Test() { var publishDate = "TestDate"; var options = TestUtilities.GetOptions(nameof(SearchBookByPublishDate_Test)); using (var actContext = new LibrarySystemContext(options)) { await actContext.Books.AddAsync(new Book { PublishDate = publishDate }); await actContext.SaveChangesAsync(); } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); var bookSearch = await sut.SearchBookAsync(null, null, null, publishDate); Assert.IsNotNull(bookSearch); } }
protected override async Task OnParametersSetAsync() { if (_categories.Count == 0) { return; } if (CategoryId == null) { var defaultCategory = _categories.First(); CategoryId = defaultCategory.Id; var newUrl = $"/books/{CategoryId}/{defaultCategory.CategoryName?.Replace(" ", "-")}"; NavigationManager.NavigateTo(newUrl); } _books = await BookWebService.GetBooksByCategory((int)CategoryId); await base.OnParametersSetAsync(); }
public async Task FindBookBookById_Test() { var id = 2; var options = TestUtilities.GetOptions(nameof(FindBookBookById_Test)); using (var actContext = new LibrarySystemContext(options)) { await actContext.Books.AddAsync(new Book { Id = id }); await actContext.SaveChangesAsync(); } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); var findBook = await sut.FindBookAsync(id); Assert.IsNotNull(findBook); } }
public async Task AddBook_Test() { var isbn = "00-23-56-43"; var title = "TestTitle"; var pages = 300; var subject = "TestSubject"; var publishers = "TestPublishers"; var publishDate = "TestPublishDate"; var author = "TestAuthor"; var picture = "TestPicture"; var options = TestUtilities.GetOptions(nameof(AddBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var sut = new BookWebService(actContext); var book = await sut.CreateBookAsync(isbn, title, pages, subject, publishers, publishDate, author, picture); Assert.IsNotNull(book); Assert.AreEqual(1, actContext.Books.Count()); } }
public async Task ReturnBook_Test() { var isbn = "TestIsbn"; var username = "******"; var reviewDto = new ReviewDto(); var lendDto = new BaseTitleDto(); var options = TestUtilities.GetOptions(nameof(ReturnBook_Test)); using (var actContext = new LibrarySystemContext(options)) { var book = await actContext.Books.AddAsync(new Book { ISBN = isbn }); var user = await actContext.Users.AddAsync(new User { UserName = username }); await actContext.SaveChangesAsync(); reviewDto.ISBN = book.Entity.ISBN; reviewDto.BookId = book.Entity.Id; reviewDto.UserId = user.Entity.Id; lendDto.Title = book.Entity.Title; lendDto.UserId = user.Entity.Id; var bookLending = new BookWebService(actContext); await bookLending.LendBookAsync(lendDto); } using (var assertContext = new LibrarySystemContext(options)) { var sut = new BookWebService(assertContext); await sut.ReturnBookAsync(reviewDto); Assert.AreEqual(0, assertContext.BookLendings.Count()); } }
public WebBookServiceWrapper(BookWebService.BookWebServiceSoap domainModel) { Infrastructure.Logging.Concrete.InfoLogger.Log("WebBookServiceWrapper", "Constructor"); this.DomainModel = domainModel; }