示例#1
0
        public async Task Test_InsertBook()
        {
            Books book = new Books(Isbn, Nmbook, Idauthor, Idpublisher)
            {
                Isbn        = "ISBN_TESTTEST",
                Nmbook      = "NAME_TEST",
                Idauthor    = 100,
                Idpublisher = 100
            };

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

            List <string[]> livro = new List <string[]>();

            bookDataAgentMock.Setup(x => x.ManipulationQuery(It.IsAny <string>()))
            .Returns("teste");

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

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#2
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);
        }
示例#3
0
        public async Task Test_SelectAllBooks()
        {
            var           bookDataAgent = new BooksDataAgent();
            IActionResult result        = await GetBooksFunction.Run(HttpRequestMock(null, null), bookDataAgent, log.Object);

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#4
0
        public async Task Test_DeleteBooks()
        {
            var    query  = new Dictionary <string, StringValues>();
            string idBook = "0000400000009";

            query.Add("isbn", idBook);

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

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#5
0
        public async Task Test_SelectAllBooks()
        {
            var bookDataAgentMock = new Mock <IBooksDataAgent>();

            List <string[]> livro = new List <string[]>();

            bookDataAgentMock.Setup(x => x.Select(It.IsAny <string>()))
            .Returns(livro);

            var booksDataAgent = new BooksDataAgent();
            var result         = await GetBooksFunction.Run(HttpRequestMock(null, null), bookDataAgentMock.Object, log.Object);

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#6
0
        public async Task Test_InsertBooks()
        {
            Books book = new Books(Isbn, Nmbook, Idauthor, Idpublisher)
            {
                Isbn        = "ISBN_TESTTEST",
                Nmbook      = "TESTE",
                Idauthor    = 10,
                Idpublisher = 10
            };

            string body = JsonConvert.SerializeObject(book);

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

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#7
0
        public async Task Test_SelectBookByID()
        {
            var bookDataAgentMock = new Mock <IBooksDataAgent>();

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

            query.Add("isbn", idBook);

            List <string[]> livro = new List <string[]>();

            bookDataAgentMock.Setup(x => x.Select(It.IsAny <string>()))
            .Returns(livro);

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

            var resultObject = (ObjectResult)result;

            Assert.Equal(200, resultObject.StatusCode);
        }
示例#8
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);
        }