public void GetNewsInstance_ShouldReturnResult() { var context = new MockNewsFeedAPIContext(); context.NewsInstances.Add(GetNewsInstance()); var controller = new NewsInstancesController(context); var result = controller.GetNewsInstance(1) as OkNegotiatedContentResult <NewsInstanceViewModel>; Assert.IsNotNull(result); Assert.AreEqual(1, result.Content.ID); }
public void GetNewsInstance_ShouldReturnNotfound() { var context = new MockNewsFeedAPIContext(); context.NewsInstances.Add(GetNewsInstance()); var controller = new NewsInstancesController(context); var result = controller.GetNewsInstance(2); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public void DeleteNewsInstance_ShouldSuccess() { var context = new MockNewsFeedAPIContext(); var controller = new NewsInstancesController(context); context.NewsInstances.Add(GetNewsInstance()); var result = controller.DeleteNewsInstance(1) as StatusCodeResult; Assert.IsNotNull(result); Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode); var result2 = controller.GetNewsInstance(1); Assert.IsNotNull(result2); Assert.IsInstanceOfType(result2, typeof(NotFoundResult)); }