Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }