public void DeleteTest_ReturnErrorViewWhenIdIsEqualToZero() { _placesService.Setup(s => s.GetById(0)) .Throws <NullReferenceException>(); var result = _placesController.Delete(0); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <ErrorViewModel>(viewResult.ViewData.Model); Assert.Equal("The place that you are looking for was not found ..", model.ErrorMessage); }
public void Should_Delete_Entity() { controller.Post(Store.TestPlace); var places = controller.Get().Content.ReadAsAsync <IEnumerable <PlaceDTO> >().Result.ToList(); Assert.IsTrue(places.DoesContain(Store.TestPlace)); var response = controller.Delete(Store.TestPlace.Key.Value); Assert.IsTrue(HttpStatusCode.NoContent == response.StatusCode); places = controller.Get().Content.ReadAsAsync <IEnumerable <PlaceDTO> >().Result.ToList(); Assert.IsFalse(places.DoesContain(Store.TestPlace)); }