Exemplo n.º 1
0
        public async Task Test_UpdateBook()
        {
            Books book = new Books(Isbn, Nmbook, Idauthor, Idpublisher)
            {
                Nmbook      = "NAME_TESTUNIT",
                Idauthor    = 49,
                Idpublisher = 49
            };

            var    query  = new Dictionary <string, StringValues>();
            string idBook = "0000000000009";

            query.Add("isbn", idBook);

            string serializedBook    = JsonConvert.SerializeObject(book);
            var    bookDataAgentMock = new Mock <IBooksDataAgent>();

            bookDataAgentMock.Setup(x => x.ManipulationQuery(It.IsAny <string>()))
            .Returns("UNIT TEST: UPDATE");

            var booksDataAgent = new BooksDataAgent();
            var result         = await PutBookFunction.Run(HttpRequestMock(query, serializedBook), bookDataAgentMock.Object, log.Object);

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
Exemplo n.º 2
0
        public async Task Test_UpdateBooks()
        {
            Books book = new Books(Isbn, Nmbook, Idauthor, Idpublisher)
            {
                Nmbook      = "NAME_TESTUNIT",
                Idauthor    = 49,
                Idpublisher = 49
            };

            string body   = JsonConvert.SerializeObject(book);
            var    query  = new Dictionary <string, StringValues>();
            string idBook = "0000000000009";

            query.Add("isbn", idBook);

            var           bookDataAgent = new BooksDataAgent();
            IActionResult result        = await PutBookFunction.Run(HttpRequestMock(query, body), bookDataAgent, log.Object);

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }