public async Task POST_Is_OK() { var controller = new RegionsController(Context); ConfigureRequest(controller); var model = new RegionModel { Name = "Test No Id" }; var result = await GetResponse(controller.Post(model)); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public async Task POST_Inserts_Records() { var controller = new RegionsController(Context); ConfigureRequest(controller); var initialCount = Context.Regions.Count(); var model = new RegionModel { Name = "Test No Id" }; var result = await GetData <RegionModel>(controller.Post(model)); Assert.IsNotNull(result); Assert.AreEqual(model.Name, result.Name); Assert.AreNotEqual(Guid.Empty, result.Id); }
public async Task POST_Fails_Duplicate_Records() { var controller = new RegionsController(Context); ConfigureRequest(controller); var model = new RegionModel { Name = "Test No Id" }; Context.Regions.Add(new Region { Name = model.Name }); Context.SaveChanges(); var result = await GetResponse(controller.Post(model)); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }