public async Task UpdateEventTest_ShouldReturn_NotFoundStatusCode_And_NullContent() { //arrange var repository = new EventRepository(new TestAppContext()); var controller = new EventController(repository); controller.Request = new HttpRequestMessage(); controller.Request.SetConfiguration(new HttpConfiguration()); //act var response = await controller.UpdateEvent(new Event { Id="agfgfgf"}); //assert Assert.IsNotNull(response); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); Assert.IsNull(response.Content); }
public async Task UpdateEventTest_ShouldReturn_BadRequestStatusCode_and_NotNullContent() { //arrange var controller = new EventController(new EventRepository()); controller.Request = new HttpRequestMessage(); controller.Request.SetConfiguration(new HttpConfiguration()); //act controller.ModelState.AddModelError("",""); var response = await controller.UpdateEvent(GetDemoEvent()); //assert Assert.IsNotNull(response); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsNotNull(response.Content); }
public async Task UpdateEventTest_ShouldReturnSameProduct_and_OkStatusCode() { //arrange var context = new TestAppContext(); context.Events.Add(GetDemoEvent()); var repository = new EventRepository(context); var controller = new EventController(repository); controller.Request = new HttpRequestMessage(); controller.Request.SetConfiguration(new HttpConfiguration()); var item = GetDemoEvent(); //act var response = await controller.UpdateEvent(item); //assert Event resultEvent; Assert.IsNotNull(response); Assert.IsNotNull(response.Content); Assert.IsTrue(response.TryGetContentValue<Event>(out resultEvent)); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.AreEqual(item.Id, resultEvent.Id); }