public void Get_AuthorById_Not_Null_Test()
        {
            databaseMock.Setup(a => a.Authors.Get(It.IsAny <int>())).Returns(new Author()
            {
                Id      = 1,
                Name    = "Test",
                Surname = "Test"
            });

            var result = authorService.GetAuthor(It.IsAny <int>());

            Assert.IsNotNull(result);
        }
Example #2
0
        public HttpResponseMessage GetAuthor(string name)
        {
            AuthorManager AuthorManager = new AuthorManager();

            try
            {
                AuthorModel author = AuthorManager.GetAuthor(name);
                if (author == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, "sorry there is no author name with the name " + name));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, author));
            }
            catch (Exception err)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, err));
            }
        }