private void Clear_Click(object sender, RoutedEventArgs e) { Isbn.Clear(); isbnmsg.Visibility = Visibility.Visible; Name.Content = ""; fkTypeCode.Content = ""; fkTypeName.Content = ""; fkPressName.Content = ""; Author.Content = ""; unifyNum.Content = ""; parallelTitle.Content = ""; postIssueNumber.Content = ""; openBook.Content = ""; issnPrice.Content = ""; releaseCycle.Content = ""; remark.Content = ""; periodicalInfo = new PeriodicalInfo(); EPC.Clear(); BookCode.Clear(); info = new CallNumberInfo(); CallNumberTxt.Clear(); callNumbermsg.Visibility = Visibility.Visible; PeriodicalCode.Clear(); PeriodicalMsg.Visibility = Visibility.Visible; sNumber.Content = ""; page.Content = ""; publicationDateStr.Content = ""; remarks.Content = ""; price.Content = ""; }
public void AddBook_RepositoryThrowsException_ThrowsException() { _repoMock .Setup(repo => repo.AddBook(It.IsAny <Book>())) .Throws(new DataException("Test data exception!")); _dataService = new DataService(_repoMock.Object, _dateProviderMock.Object); var isbn = new Isbn("979-3-16-148410-0"); var exception = Assert.ThrowsException <DataServiceException>( () => _dataService.AddBook(isbn, "Title", "Author") ); Assert.IsInstanceOfType(exception.InnerException, typeof(DataException)); Predicate <Book> validator = e => e.Isbn == isbn && e.Name == "Title" && e.Author == "Author"; _repoMock.Verify( repo => repo.AddBook(Match.Create <Book>(validator)), Times.Once() ); }
public void The_Hyphens_In_An_Isbn_Do_Not_Affect_Hashcode() { var one = new Isbn("978-0-123456789"); var other = new Isbn("9780123456789"); one.GetHashCode().Equals(other.GetHashCode()).Should().BeTrue(); }
public int Update(Isbn param, SqlTransaction transaccion) { string query = " UPDATE Cat_ISBN SET ISBN = @isbn, desc_ver = @descripcion, reimpresion = @reimpresion, reedicion = @reedicion "; query = query + " WHERE id_tit_isbn = @idIsbn ; "; SqlParameter param1 = new SqlParameter() { ParameterName = "@isbn", Direction = System.Data.ParameterDirection.Input, SqlDbType = System.Data.SqlDbType.NVarChar, Size = 50, Value = param.ClaveIsbn.Trim() }; SqlParameter param2 = new SqlParameter() { ParameterName = "@descripcion", Direction = System.Data.ParameterDirection.Input, SqlDbType = System.Data.SqlDbType.NVarChar, IsNullable = true, Value = (String.IsNullOrEmpty(param.DescripcionVersion) ? DBNull.Value : (object)param.DescripcionVersion.Trim()) }; SqlParameter param3 = new SqlParameter() { ParameterName = "@reimpresion", Direction = System.Data.ParameterDirection.Input, SqlDbType = System.Data.SqlDbType.NChar, Size = 10, IsNullable = true, Value = (String.IsNullOrEmpty(param.Reimpresion) ? DBNull.Value : (object)param.Reimpresion.Trim()) }; SqlParameter param4 = new SqlParameter() { ParameterName = "@reedicion", Direction = System.Data.ParameterDirection.Input, SqlDbType = System.Data.SqlDbType.NChar, Size = 10, IsNullable = true, Value = (String.IsNullOrEmpty(param.Reedicion) ? DBNull.Value : (object)param.Reedicion.Trim()) }; SqlParameter param5 = new SqlParameter() { ParameterName = "@idIsbn", Direction = System.Data.ParameterDirection.Input, SqlDbType = System.Data.SqlDbType.NChar, Size = 10, Value = param.IdIsbn.Trim() }; List <SqlParameter> parametros = new List <SqlParameter>() { param1, param2, param3, param4, param5 }; int result = this.Ejecutar(query, CommandType.Text, parametros, transaccion); return(result); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Isbn != null) { hashCode = hashCode * 59 + Isbn.GetHashCode(); } if (Titulo != null) { hashCode = hashCode * 59 + Titulo.GetHashCode(); } if (Autor != null) { hashCode = hashCode * 59 + Autor.GetHashCode(); } if (Genero != null) { hashCode = hashCode * 59 + Genero.GetHashCode(); } if (Data != null) { hashCode = hashCode * 59 + Data.GetHashCode(); } if (Preco != null) { hashCode = hashCode * 59 + Preco.GetHashCode(); } return(hashCode); } }
public void InvalidIsbnCode13Test(string value) { var code = Isbn.Create(TypeIsbn.Isbn13, value); Assert.True(code.IsFailure); Assert.Equal("Invalid ISBN code", code.Error); }
public async Task <bool> DeleteOneBookAsync(string isbn, CancellationToken cancellationToken) { Book model = await _Book.Table.Where(c => c.ISBNs.Where(s => s.Value == isbn) != null).SingleOrDefaultAsync(cancellationToken); if (model == null) { return(false); } if (model.ISBNs.Count <= 1) { model.BookIsDeleted = true; await _Book.UpdateAsync(model, cancellationToken); return(true); } Isbn _isbn = await _isbnRepository.Table.Where(c => c.Value == isbn).SingleOrDefaultAsync(cancellationToken); if (_isbn == null) { return(false); } await _isbnRepository.DeleteAsync(_isbn, cancellationToken); await _Book.UpdateAsync(model, cancellationToken); return(true); }
public void ValidIsbnCode13Test(string value) { var code = Isbn.Create(TypeIsbn.Isbn13, value); Assert.True(code.IsSuccess); Assert.Equal(code.Value.IsbnCode, value); }
public Book(Isbn isbn, string title, string description, uint version) { Isbn = isbn; Title = title; Description = description; Version = version; }
public static void ValidaIsbn(Isbn isbn, string mensagem) { if (isbn.EhValido() is false) { Erros.Add(mensagem); } }
public Book(string title, string author, DateTimeOffset published, Isbn isbn) { Title = title; Author = author; Published = published; Isbn = isbn; }
private void CheckBookIsbn(Isbn isbn) { if (!_dataContext.books.ContainsKey(isbn)) { throw new DataNotExistsException(); } }
public Task ExecuteAsync(IConsole console) { // To make the demo simpler, we will just generate random publish date and ISBN if they were not set if (Published == default) { Published = CreateRandomDate(); } if (Isbn == default) { Isbn = CreateRandomIsbn(); } if (_libraryService.GetBook(Title) != null) { throw new CommandException("Book already exists.", 1); } var book = new Book(Title, Author, Published, Isbn); _libraryService.AddBook(book); console.Output.WriteLine("Book added."); console.RenderBook(book); return(Task.CompletedTask); }
public DateTime?AplicaFechaMaxima(string isbn) { char[] charArray = Isbn.ToLower().ToCharArray(); int sum = 0; DateTime fechaMaxima; foreach (var item in charArray) { int number; int.TryParse(item.ToString(), out number); sum = sum + number; } if (sum > 30) { fechaMaxima = DateTime.Now; int dias = 0; while (dias < 14) { if (fechaMaxima.DayOfWeek == DayOfWeek.Sunday) { fechaMaxima = fechaMaxima.AddDays(1); } else { fechaMaxima = fechaMaxima.AddDays(1); dias++; } } return(fechaMaxima); } else { return(null); } }
public void ToString_With_Invalid_Format_By_Case_Throws_FormatException() { var sut = new Isbn("978-0-123456789"); Action action = () => sut.ToString("o"); action.Should().Throw <FormatException>(); }
public void EditBookDetailsTest() { var faker = new Faker(); var author = new Author(FullName.Create(faker.Name.FirstName(), faker.Name.LastName()).Value); var bookCategory = BookCategory.Create(CategoryBook.Business, faker.Lorem.Text()).Value; var bookDescription = BookDescription .Create(faker.Lorem.Text(), faker.Date.Random.Number(1, DateTime.Now.Year)).Value; var bookIsbn = Isbn.Create(TypeIsbn.Isbn10, "ISBN 1-58182-008-9").Value; var book = new Books(author, bookCategory, bookDescription, bookIsbn); var oldId = book.BookId.Value; Assert.NotNull(book); var newAuthor = new Author(FullName.Create(faker.Name.FirstName(), faker.Name.LastName()).Value); var newBookCategory = BookCategory.Create(CategoryBook.Business, faker.Lorem.Text()).Value; var newBookDescription = BookDescription .Create(faker.Lorem.Text(), faker.Date.Random.Number(1, DateTime.Now.Year)).Value; var newBookIsbn = Isbn.Create(TypeIsbn.Isbn10, "ISBN 1-55182-008-9").Value; book.EditBookDetails(newAuthor, newBookCategory, newBookDescription, newBookIsbn); Assert.NotEqual(book.Author.FullName.SureName, author.FullName.Name); Assert.NotEqual(book.Author.FullName.SureName, author.FullName.Name); Assert.NotEqual(book.BookCategory.CategoryName, bookCategory.CategoryName); Assert.NotEqual(book.BookDescription.Title, bookDescription.Title); Assert.NotEqual(book.BookDescription.Year, bookDescription.Year); Assert.NotEqual(book.Isbn.IsbnCode, bookIsbn.IsbnCode); Assert.Equal(oldId, book.BookId.Value); }
private bool CheckIsbn(Isbn isbn) { var check = (from i in _db.Books where i.Isbn == isbn select i); return(check.Any()); }
public List <Book> GetBookByIsbn(Isbn isbn) { var book = (from books in _db.Books where books.Isbn == isbn select books).ToList(); return(book); }
public void The_Hyphens_In_An_Isbn_Do_Not_Affect_Equality() { var one = new Isbn("978-0-123456789"); var other = new Isbn("9780123456789"); one.Equals(other).Should().BeTrue(); (one == other).Should().BeTrue(); }
public void TestToString(string inputString, IsbnFormat format, string expectedResult) { var isbn = new Isbn(inputString); var actualResult = isbn.ToString(format); Assert.AreEqual(expectedResult, actualResult); }
public async Task Delete(Isbn isbn) { var isbnString = IsbnToString(isbn); await _dbContext.DeleteAsync <BookDocument>(isbnString); await _bookQueuePublisher.Notify(BookAction.Deleted, isbn); }
public void InvalidIsbnCodeTest() { var code = Isbn.Create(TypeIsbn.Isbn10, string.Empty); var expectedResult = "Missing ISBN type or isbnCode is empty"; Assert.True(code.IsFailure); Assert.Equal(expectedResult, code.Error); }
public int CompareTo(Book book) { if (book == null) { throw new ArgumentNullException(); } return(Isbn.CompareTo(book.Isbn)); }
private async void Button_Clicked(object sender, EventArgs e) { Loading.IsVisible = Loading.IsRunning = true; var book = Isbn.GetBook(isbn.Text).Result; await connect.InsertAsync(book); await Navigation.PopAsync(); }
public Livro GerarLivroValido() { Cpf cpf = new Cpf("515.523.840-47"); Nome nome = new Nome("Thiago", "Moreira"); Autor autor = new Autor(nome, new DateTime(1982, 4, 6), cpf); Isbn isbn = new Isbn("978-12-345-6789-7"); return(new Livro("teste", DateTime.Now, isbn, "ficção", autor)); }
public Livro GerarLivroInvalido() { Cpf cpf = new Cpf("515.523.840-47"); Nome nome = new Nome("Thiago", "Moreira"); Autor autor = new Autor(nome, new DateTime(1982, 4, 6), cpf); Isbn isbn = new Isbn("111-11-111-1111-1"); return(new Livro("", DateTime.Now, isbn, "", autor)); }
public void ToString_With_Original_Format() { var sut = new Isbn("978-0-123456789"); sut.ToString("O").Should().Be("978-0-123456789"); sut.ToString("G").Should().Be("978-0-123456789"); sut.ToString("").Should().Be("978-0-123456789"); sut.ToString((string)null).Should().Be("978-0-123456789"); }
public async Task <BookDto> Handle(GetBookByIsbnQuery query, CancellationToken cancellationToken) { var storage = await _storageRepository.GetAsync(_storageConfig.DevelopStorageId); var isbn = new Isbn(query.Isbn); var book = storage.Books.FirstOrDefault(x => x.BookInformation.Isbn.Equals(isbn)); return(book is null ? null : _mapper.Map <BookDto>(book)); }
public void TestBookProperties() { var book = new Book(); var publisher = new Publisher("Publisher Test"); var author1 = new Author("Test Author"); author1.Id = 2; var a = new Author("Test") { Id = 1 }; var author2 = new Author("Author Test") { Id = 2 }; var bookAuthors = new List <BookAuthor>() { new BookAuthor() { Book = book, BookId = book.Id, Author = author1, AuthorId = author1.Id }, new BookAuthor() { Book = book, BookId = book.Id, Author = author2, AuthorId = author2.Id }, }; var isbn = Isbn.FromValue("9788574591865"); var synopsis = "Synopsis"; var numberOfCopies = 2; book.Title = "Test"; book.Id = 3; book.Publisher = publisher; book.Authors = bookAuthors; book.Isbn = isbn; book.Synopsis = synopsis; book.PublicationYear = 2002; book.NumberOfCopies = numberOfCopies; Assert.IsNotNull(book); Assert.AreEqual("Test", book.Title); Assert.AreEqual(3, book.Id); Assert.AreEqual(2002, book.PublicationYear); Assert.AreEqual(publisher, book.Publisher); Assert.AreEqual(isbn, book.Isbn); Assert.AreEqual(synopsis, book.Synopsis); Assert.AreEqual(numberOfCopies, book.NumberOfCopies); bookAuthors.AssertListEquals(book.Authors); }
public LibraryBook(Isbn isbn, DateTime published, string title, string author = No_Author, int quantity = 0, string content = "not digitalized") { this.ISBN = isbn; this.Title = title; this.Author = author; this.Quantity = quantity; this.Published = published; this.Content = content; this.Borrowed = 0; }
public ShopBook(Isbn isbn, DateTime published, string title, string author, int quantity, string content, double price) : base(isbn: isbn, published: published, title: title, author: author, quantity: quantity, content: content) { this.Price = price; }
public void TestGetIsbnCheckValueProperties() { var isbn = Isbn.FromValue("9788574591865"); isbn.Id = 3; Assert.IsNotNull(isbn); Assert.AreEqual("9788574591865", isbn.Value); Assert.AreEqual(3, isbn.Id); }