public async Task Patch_NotExistingEntity() { using (IDataContext context = GetDataContext()) using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger())) { //Arrange MeetingsController controller = new MeetingsController(uow); await SetupData(controller, uow); // Expected Meeting expected = mockmeetings.ElementAt(1); Delta<Meeting> delta = new Delta<Meeting>(typeof(Meeting)); delta.TrySetPropertyValue("VenueName", expected.VenueName + " Patched"); //Act IHttpActionResult response = await controller.Patch(1, delta); // Assert Assert.IsNotNull(response, "A response equal to null is unexpected!"); Assert.IsInstanceOfType(response, typeof(NotFoundResult)); } }
public async Task Patch() { using (IDataContext context = GetDataContext()) using (IRaceDataUnitOfWork uow = new RaceDataUnitOfWork(context, new Logger())) { //Arrange MeetingsController controller = new MeetingsController(uow); await SetupData(controller, uow, false); // Expected Meeting expected = mockmeetings.ElementAt(0); Delta<Meeting> delta = new Delta<Meeting>(typeof(Meeting)); delta.TrySetPropertyValue("VenueName", expected.VenueName + " Patched"); //Act IHttpActionResult post_response = await controller.Post(mockmeetings.ElementAt(0)); CreatedNegotiatedContentResult<Meeting> post_actual = post_response as CreatedNegotiatedContentResult<Meeting>; // Assert Assert.IsNotNull(post_actual, "A response equal to null is unexpected!"); //Act IHttpActionResult response = await controller.Patch(post_actual.Content.Id, delta); UpdatedODataResult<Meeting> actual = response as UpdatedODataResult<Meeting>; // Assert Assert.IsNotNull(actual, "A response equal to null is unexpected!"); Assert.AreEqual(actual.Entity.VenueName, expected.VenueName); Assert.AreEqual(actual.Entity.NumberOfRaces, expected.NumberOfRaces); Assert.AreEqual(actual.Entity.Coverages.Count(), expected.Coverages.Count()); Assert.AreEqual(actual.Entity.RaceStarts.Count(), expected.RaceStarts.Count()); } }