예제 #1
0
 public void TestGenericThrowsTestMethodReturnTaskWithoutParametersAsync()
 {
     Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(), () =>
     {
         Assert.ThrowsAsync <Exception>(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync());
     });
 }
예제 #2
0
    public async Task TestGenericSetupReturnsAsyncMethodsReturnTaskAsync()
    {
        var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync();

        Assert.AreEqual(1, originalResult);
        var expectedResult = 2;

        Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(), async() =>
        {
            var actualResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync();
            Assert.AreEqual(expectedResult, actualResult);
        }).ReturnsAsync(expectedResult);
    }
예제 #3
0
    public async Task TestSetupReturnsMethodsReturnTaskAsync()
    {
        var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync();

        Assert.AreEqual(1, originalResult);
        var expectedResult = 2;

        Mock.Setup(typeof(TestStaticClass), nameof(TestStaticClass.TestMethodReturnTaskWithoutParametersAsync), async() =>
        {
            var actualResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync();
            Assert.AreEqual(expectedResult, actualResult);
        }).Returns(Task.FromResult(expectedResult));
    }