我的 单元测试 返回错误说明:System.InvalidOperationException: Sequence contains no matching element.
当我开始调试时,它会在点击var result = _forgotPass.SendEmail(...);
之后自动停止调试器。为什么它会抛出此异常
以及如何解决这个问题?
错误: System.InvalidOperationException: Sequence contains no matching element.
单元测试:
[TestMethod]
public void SendEmail()
{
//Arrange
_getUrl.Setup(mock => mock.AddUrlLink(It.IsAny<string>())).Returns(new ApiResponse<Status, string>(Status.Success, "link"));
_emailMock.Setup(mock => mock.Send(It.IsAny<CarrierModel>())).Returns(new ApiResponse<bool, string>(false, ""));
//Act
var result = _forgotPass.SendEmail("myemail@gmail.com");
//Assert
Assert.AreEqual(Status.EmailFailed, result.Status);
Assert.IsNull(result.Body);
Assert.IsTrue(result.Messages.Any(m => m == "Email Failed"));
}