コード例 #1
0
        public void GetSearchErrorMessage()
        {
            var mockRequestModel = new Request();

            var mockBeerProvide = new Moq.Mock <IBeerProvider>();

            var controller = new BeerController(mockBeerProvide.Object);

            IHttpActionResult actionResult = controller.SearchBeers(mockRequestModel);

            Assert.IsNotNull(actionResult);
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
コード例 #2
0
        public void GetSearchReturnResult(string queryRequest)
        {
            var mockRequestModel = new Request {
                query = queryRequest
            };

            var mockBeersModel = new Beers();

            var mockBeerProvide = new Moq.Mock <IBeerProvider>();

            mockBeerProvide.Setup(x => x.SearchBeers(mockRequestModel)).Returns(mockBeersModel);
            var controller = new BeerController(mockBeerProvide.Object);

            //Act
            IHttpActionResult actionResult = controller.SearchBeers(mockRequestModel);

            //Assert
            Assert.IsNotNull(actionResult);
            Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult <Beers>));
        }