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