public void DeleteBook() { var controller = new BookCatalogueController(BookCatalogueContext); var actionResult = controller.Delete("string"); var contentResult = (Microsoft.AspNetCore.Mvc.OkResult)actionResult.Result; Assert.IsNotNull(actionResult); Assert.AreEqual(200, contentResult.StatusCode); }
public void GetBookByISBN() { var controller = new BookCatalogueController(BookCatalogueContext); var actionResult = controller.Get("978-1734314502"); var contentResult = (ObjectResult)actionResult.Result; Assert.AreEqual(200, contentResult.StatusCode); Assert.AreEqual("978-1734314502", ((Book)((ObjectResult)actionResult.Result).Value).ISBN); }
public void UpdateBook() { var controller = new BookCatalogueController(BookCatalogueContext); var book = new Book(); book.PublicationDate = System.DateTime.Now; book.Title = "You Can Win"; var actionResult = controller.Update("9781581130225", book); var contentResult = (ObjectResult)actionResult.Result; Assert.IsNotNull(actionResult); Assert.AreNotEqual(200, contentResult.StatusCode); }
public void CreateBook() { var controller = new BookCatalogueController(BookCatalogueContext); var author = new Author(); author.Name = "Shive Khera"; var book = new Book(); book.Authors = new System.Collections.Generic.List <Author>(); book.Authors.Add(author); book.ISBN = "9781581130225"; book.PublicationDate = System.DateTime.Now; book.Title = "You Can Win"; var actionResult = controller.Create(book); var contentResult = (ObjectResult)actionResult.Result; Assert.IsNotNull(actionResult); Assert.AreEqual(200, contentResult.StatusCode); }