public void Get_ThrowsEntityNotFoundException() { var groupServiceStub = new Mock <IGroupService>(); groupServiceStub.Setup(x => x.GetGroups()).Throws(new EntityNotFoundException()); var target = new GroupsController(groupServiceStub.Object); var expected = target.NotFound(new EntityNotFoundException().Message); var actual = target.Get() as NotFoundObjectResult; Assert.IsNotNull(actual); Assert.AreEqual(expected.Value, actual.Value); Assert.AreEqual(expected.StatusCode, actual.StatusCode); }
public void Get_WhenByQuery_ThrowsEntityNotFoundException() { var groupServiceStub = new Mock <IGroupService>(); groupServiceStub .Setup(x => x.GetGroups(It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <string[]>())) .Throws(new EntityNotFoundException()); var target = new GroupsController(groupServiceStub.Object); var expected = target.NotFound(new EntityNotFoundException().Message); var actual = target.Get("name1", 1, null) as NotFoundObjectResult; Assert.IsNotNull(actual); Assert.AreEqual(expected.Value, actual.Value); Assert.AreEqual(expected.StatusCode, actual.StatusCode); }