public void getContactType() { // Arrange ContactTypeController controller = new ContactTypeController(); var actResult = controller.Get(1); // Act var result = actResult as OkNegotiatedContentResult <ContactType>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content.ID == 1); }
public async void Get_Not_Exists() { ContactTypeControllerMockFacade mock = new ContactTypeControllerMockFacade(); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiContactTypeResponseModel>(null)); ContactTypeController controller = new ContactTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Get(default(int)); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }