public void GetTestResult_GeneralErrorTest() { var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object); var exception = "I am an exception"; tgimbaService.Setup(x => x.GetTestResult()) .Throws(new Exception(exception)); IActionResult result = tgimbaApi.GetTestResult(); StatusCodeResult requestResult = (StatusCodeResult)result; tgimbaService.Verify(x => x.Log(It.Is <string>(s => s == exception)), Times.Once); Assert.IsNotNull(requestResult); Assert.AreEqual(500, requestResult.StatusCode); }
public void GetTestResult_HappyPathTest() { var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object); tgimbaService.Setup(x => x.GetTestResult()) .Returns(Constants.API_TEST_RESULT); IActionResult result = tgimbaApi.GetTestResult(); OkObjectResult requestResult = (OkObjectResult)result; Assert.IsNotNull(requestResult); Assert.AreEqual(200, requestResult.StatusCode); tgimbaService.Verify(x => x.GetTestResult(), Times.Once); var testResult = (string)requestResult.Value; Assert.AreEqual(Constants.API_TEST_RESULT, testResult); }