示例#1
0
        public void BeersApiController_GetOne()
        {
            BeersApiController controller           = new BeersApiController(new FakeRepositories.FakeBeerRepository());
            OkNegotiatedContentResult <Beer> result = controller.GetBeer(10) as OkNegotiatedContentResult <Beer>;

            Assert.IsNotNull(result);
        }
示例#2
0
        public void BeersApiController_GetAll()
        {
            BeersApiController controller = new BeersApiController(new FakeRepositories.FakeBeerRepository());
            var result = controller.GetBeers() as List <Beer>;

            Assert.IsNotNull(result);
        }
示例#3
0
        public void BeersApiController_AddAction()
        {
            BeersApiController controller = new BeersApiController(new FakeRepositories.FakeBeerRepository());
            Beer beer = new Beer()
            {
                BeerId    = 1,
                Name      = "Blue Brew",
                Type      = "Ale",
                UnitPrice = 69,
                ABV       = 69
            };

            System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Beer> result = controller.PostBeer(beer) as CreatedAtRouteNegotiatedContentResult <Beer>;
            Assert.IsNotNull(result);
        }
示例#4
0
        public void BeersApiController_Edit()
        {
            BeersApiController controller = new BeersApiController(new FakeRepositories.FakeBeerRepository());
            Beer beer = new Beer()
            {
                BeerId    = 1,
                Name      = "GreasyKev",
                Type      = "Ale",
                UnitPrice = 1,
                ABV       = 1
            };

            System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Beer> createBeer = controller.PostBeer(beer) as CreatedAtRouteNegotiatedContentResult <Beer>;
            IHttpActionResult edit = controller.PutBeer(10, beer) as IHttpActionResult;

            Assert.IsNotNull(createBeer);
            Assert.IsNotNull(edit);
        }
示例#5
0
        public void BeersApiController_DeleteAction()
        {
            BeersApiController controller = new BeersApiController(new FakeRepositories.FakeBeerRepository());

            Beer beer = new Beer()
            {
                BeerId    = 1,
                Name      = "BeeBrew",
                Type      = "Ale",
                UnitPrice = 5,
                ABV       = 4
            };

            System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Beer> createBeer = controller.PostBeer(beer) as CreatedAtRouteNegotiatedContentResult <Beer>;
            System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Beer> delete     = controller.DeleteBeer(1) as CreatedAtRouteNegotiatedContentResult <Beer>;
            System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Beer> result     = controller.GetBeer(1) as CreatedAtRouteNegotiatedContentResult <Beer>;
            Assert.IsNotNull(createBeer);
            Assert.IsNull(result);
        }