Exemplo n.º 1
0
 public void TestGenericThrowsTestMethodReturnTaskWithoutParameters()
 {
     Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParameters(), () =>
     {
         Assert.ThrowsAsync <Exception>(() => TestStaticClass.TestMethodReturnTaskWithoutParameters());
     });
 }
Exemplo n.º 2
0
    public async Task TestGenericSetupReturnsAsyncMethodsReturnTask()
    {
        var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParameters();

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

        Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParameters(), async() =>
        {
            var actualResult = await TestStaticClass.TestMethodReturnTaskWithoutParameters();
            Assert.AreEqual(expectedResult, actualResult);
        }).ReturnsAsync(expectedResult);
    }
Exemplo n.º 3
0
    public async Task TestSetupReturnsMethodsReturnTask()
    {
        var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParameters();

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

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