public async void TestAddSiteCreatesSite() { EntityContext entityContext = CreateEntityContext(); loadEntityContextWithData(entityContext); SitesController sitesController = new SitesController(entityContext, CreateLogger()); await sitesController.AddSite(CreateSite("999888777", "Site for Add Test")); Site site = entityContext.Sites.Find("999888777"); Assert.Equal("999888777", site.NPI); Assert.Equal("Site for Add Test", site.SiteName); }
public void TestAddSiteSetsSiteInResult() { EntityContext entityContext = CreateEntityContext(); loadEntityContextWithData(entityContext); SitesController sitesController = new SitesController(entityContext, CreateLogger()); Task <ActionResult <Site> > result = sitesController.AddSite(CreateSite("999888777", "Site for Add Test")); var actionResult = Assert.IsType <ActionResult <Site> >(result.Result); var createdAtResult = Assert.IsType <CreatedAtActionResult>(actionResult.Result); var site = Assert.IsType <Site>(createdAtResult.Value); Assert.Equal("999888777", site.NPI); Assert.Equal("Site for Add Test", site.SiteName); }
public void TestAddSiteSetsNPIRouteValue() { EntityContext entityContext = CreateEntityContext(); loadEntityContextWithData(entityContext); SitesController sitesController = new SitesController(entityContext, CreateLogger()); Task <ActionResult <Site> > result = sitesController.AddSite(CreateSite("999888777", "Site for Add Test")); var actionResult = Assert.IsType <ActionResult <Site> >(result.Result); var createdAtResult = Assert.IsType <CreatedAtActionResult>(actionResult.Result); object resultNPI; createdAtResult.RouteValues.TryGetValue("NPI", out resultNPI); Assert.Equal("999888777", resultNPI); }