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); }
public void BarsApiController_AddAction() { BarsApiController controller = new BarsApiController(new FakeRepositories.FakeBarRepository()); Bar bar = new Bar() { Name = "Kelsey's", Address = "Oakville", StoreId = 7, UnitsOrdered = 8, }; System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Bar> result = controller.PostBar(bar) as CreatedAtRouteNegotiatedContentResult <Bar>; Assert.IsNotNull(result); }
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); }
public void BarsApiController_Edit() { BarsApiController controller = new BarsApiController(new FakeRepositories.FakeBarRepository()); Bar bar = new Bar() { Name = "Cheers", Address = "Toronto", StoreId = 10, UnitsOrdered = 100, }; System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Bar> result = controller.PostBar(bar) as System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Bar>; IHttpActionResult edit = controller.PutBar(10, bar) as IHttpActionResult; Assert.IsNotNull(result); Assert.IsNotNull(edit); }
public void BrewariesApiController_Edit() { BreweriesApiController controller = new BreweriesApiController(new FakeRepositories.FakeBrewaryRepository()); Brewery brew = new Brewery() { Name = "Molson", Address = "Toronto", YTDSales = 5030, BreweryId = 7 }; System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Brewery> result = controller.PostBrewery(brew) as System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Brewery>; IHttpActionResult edit = controller.PutBrewery(10, brew) as IHttpActionResult; Assert.IsNotNull(result); Assert.IsNotNull(edit); }
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); }
public void BrewariesApiController_Delete() { BreweriesApiController controller = new BreweriesApiController(new FakeRepositories.FakeBrewaryRepository()); Brewery brew = new Brewery() { Name = "Molson", Address = "Toronto", YTDSales = 5030, BreweryId = 7 }; System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Brewery> result = controller.PostBrewery(brew) as System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Brewery>; OkNegotiatedContentResult <Brewery> deleteResult = controller.DeleteBrewery(7) as OkNegotiatedContentResult <Brewery>; Assert.IsNotNull(result); Assert.IsNotNull(deleteResult); }
public void Post() { CategoriasController controller = new CategoriasController(container); Categoria categoria = new Categoria(); categoria.Id = 4; categoria.Descricao = "Mobile"; categoria.Slug = "mobile"; System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Categoria> result = (System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <Categoria>)controller.PostCategoria(categoria); Assert.IsNotNull(result); Assert.AreEqual("mobile", result.Content.Slug); Assert.IsNotNull(container.GetCategoria(4)); }