public void SetGrades(BookInstance book) { book.AddGrade(90.0); book.AddGrade(85.0); book.AddGrade(80.0); book.AddGrade(70.0); }
public void AddBookInstance(int bookInstanceId, BookInstance instance) { var book = _bookRepository.GetById(bookInstanceId); instance.Book = book; _bookInstanceRepository.Create(instance); _unitOfWork.Save(); }
public void CheckNoStatistics() { //arrange var book = new BookInstance(); Statistics expected = new Statistics(); expected.Total = 0.0; expected.Average = 0.0; expected.High = 0.0; expected.Low = 0.0; Statistics actual = book.GetStatistics(); //act //assert Assert.Equal(expected.High, actual.High); Assert.Equal(expected.Low, actual.Low); Assert.Equal(expected.Average, actual.Average); Assert.Equal(expected.Total, actual.Total); }
public void CheckStatistics() { //arrange var book = new BookInstance(); SetGrades(book); Statistics expected = new Statistics(); expected.Total = 325.0; expected.Average = 81.25; expected.High = 90.0; expected.Low = 70.0; Statistics actual = book.GetStatistics(); //act //assert Assert.Equal(expected.High, actual.High); Assert.Equal(expected.Low, actual.Low); Assert.Equal(expected.Average, actual.Average); Assert.Equal(expected.Total, actual.Total); }
public async Task AddAsync(BookDetails book) { Book entity = new Book() { Title = book.Title, Summary = book.Summary, Thumbnail = book.Thumbnail, Isbn13 = book.Isbn13, Isbn10 = book.Isbn10, OwnerId = book.OwnerId }; _context.Books.Add(entity); await _context.SaveChangesAsync(); BookInstance bookInstance = new BookInstance() { BookId = entity.BookId, Added = DateTime.UtcNow }; _context.BookInstances.Add(bookInstance); await _context.SaveChangesAsync(); }
/// <summary> /// Add a new book instance to that product /// </summary> /// <param name="title"></param> /// <param name="isbn"></param> /// <param name="product_mode"></param> /// <param name="sPublisherNumber"></param> /// <param name="sPublisherName"></param> /// <param name="productID"></param> /// <param name="subtitle"></param> /// <param name="edition"></param> /// <param name="copyRightYear"></param> /// <param name="desc"></param> /// <param name="BindingTypeNumber"></param> /// <returns></returns> public BookInstance AddBookInstance(string title, string isbn, string product_mode, ref string sPublisherNumber, ref string sPublisherName, decimal productID, string subtitle, string edition, string copyRightYear, string desc, string BindingTypeNumber = "") { SDSPortalApplication app = new SDSPortalApplication(); BookInstance _bookinstance = new BookInstance(); string[] sTitle = title.Split('^'); if (sTitle.Length > 0 && sTitle.Length > 1 && product_mode == "existing") { _bookinstance.BOOK_TITLE = sTitle[0]; string[] sBookNumberPublisher = sTitle[1].Split(','); if (sBookNumberPublisher.Length > 1) { sPublisherNumber = sBookNumberPublisher[1]; // GetPublisher(_book.BOOK_NUMBER, "book") ; sPublisherName = _publishersController.GetPublisherName(sPublisherNumber); } } else { _bookinstance.BOOK_TITLE = title; } _bookinstance.PRODUCT_ID = productID; _bookinstance.DATE_ADDED = DateTime.Now; _bookinstance.BOOK_SUBTITLE = subtitle; _bookinstance.BOOK_EDITION = edition; _bookinstance.BOOK_COPYRIGHT_YR = copyRightYear; _bookinstance.DESCRIPTION = desc; Book _book = AddBook(isbn, sPublisherNumber, sPublisherName, _bookinstance.BOOK_TITLE, BindingTypeNumber); _bookinstance.BOOK_ID = _book.BOOK_ID; _bookinstance.Add(app.SDSConnection); return(_bookinstance); }