public void LogException_ErrorInfo_Test() { // Arrange TestableElmahErrorHelper helper = new TestableElmahErrorHelper(); ErrorInfo info = new ErrorInfo(); // Act helper.LogException(info); // Assert Assert.NotNull(helper.Error); }
public void Log_Returns_HttpStatusCodeResult_200_Test() { // Arrange TestableElmahErrorHelper helper = new TestableElmahErrorHelper(); Mock<IErrorService> service = new Mock<IErrorService>(); service.Setup(x => x.ValidateToken(It.IsAny<string>())).Returns(true); service.Setup(x => x.ValidateErrorInfo(It.IsAny<ErrorInfo>())).Returns(true); ErrorController controller = new ErrorController(helper, service.Object); ErrorInfo info = new ErrorInfo(new Exception("Test-Exception")); string xml = Utility.SerializeXml(info); string error = Convert.ToBase64String(Encoding.UTF8.GetBytes(xml)); // Act HttpStatusCodeResult result = controller.Log("Test-Token", error) as HttpStatusCodeResult; // Assert Assert.Equal(200, result.StatusCode); Assert.NotNull(helper.Error); }