public void UpdateBook_When_BookUpdated_ReturnsOk() { var ticks = DateTime.UtcNow.Ticks; var updatedBook = new BookRequest { ISBN = EXISTING_BOOK, Title = "Existing Book", Author = "Existing Author", Publisher = "Existing Publisher", CoverUrl = $"{ticks}", Price = 10, ReducedPrice = 5, AvailableCopies = 5, TotalCopies = 5 }; var request = BookRequestHelper.UpdateBook(shopName, updatedBook.ISBN, updatedBook); var response = this.restClient.Execute <BookResponse>(request); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Data); Assert.AreEqual(updatedBook.ISBN, response.Data.ISBN); Assert.AreEqual(updatedBook.Title, response.Data.Title); Assert.AreEqual(updatedBook.CoverUrl, response.Data.CoverUrl); }
public void UpdateBook_When_BookDoesNotExist_ReturnsNotFound() { var updatedBook = new BookRequest { ISBN = NON_EXISTING_BOOK, Title = "Non Existing Book", Author = "Non Existing Author", Publisher = "Non Existing Publisher", CoverUrl = null, Price = 10, ReducedPrice = 5, AvailableCopies = 5, TotalCopies = 5 }; var request = BookRequestHelper.UpdateBook(shopName, NON_EXISTING_BOOK, updatedBook); var response = this.restClient.Execute <BookResponse>(request); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); }
public void UpdateBook_When_BookUpdatedWithDifferentISBN_ReturnsBadRequest() { var ticks = DateTime.UtcNow.Ticks; var updatedBook = new BookRequest { ISBN = EXISTING_BOOK + 1, Title = "Existing Book", Author = "Existing Author", Publisher = "Existing Publisher", CoverUrl = $"{ticks}", Price = 10, ReducedPrice = 5, AvailableCopies = 5, TotalCopies = 5 }; var request = BookRequestHelper.UpdateBook(shopName, EXISTING_BOOK, updatedBook); var response = this.restClient.Execute <BookResponse>(request); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public void UpdateBook_When_ShopDoesNotExist_ReturnsNotFound() { var ticks = DateTime.UtcNow.Ticks; var updatedBook = new BookRequest { ISBN = EXISTING_BOOK, Title = "Existing Book", Author = "Existing Author", Publisher = "Existing Publisher", CoverUrl = $"{ticks}", Price = 10, ReducedPrice = 5, AvailableCopies = 5, TotalCopies = 5 }; var request = BookRequestHelper.UpdateBook("UnexistingShop", updatedBook.ISBN, updatedBook); var response = this.restClient.Execute <BookResponse>(request); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); }