SvetlovA / static-mock

SMock is opensource lib for mocking static and instance methods and properties.
https://svetlova.github.io/static-mock/
MIT License
10 stars 3 forks source link

CallbackAsync throws throws Exception on Setup #8

Closed SvetlovA closed 2 years ago

SvetlovA commented 2 years ago

If you throws custom exception from CallbackAsync this exception throws on setup

Failed test example:

    [Test]
    public async Task TestCallbackAsyncInstanceThrows()
    {
        var instance = new TestInstance();
        var originalResult = await instance.TestMethodReturnTaskWithoutParametersAsync();
        var expectedResult = 2;

        Assert.AreNotEqual(expectedResult, originalResult);

        Mock.Setup(() => instance.TestMethodReturnTaskWithoutParametersAsync(), async () =>
        {
            Assert.ThrowsAsync<Exception>(async () => await instance.TestMethodReturnTaskWithoutParametersAsync());
        }).CallbackAsync(() => throw new Exception());
    }