public void TestGenericThrowsTestMethodReturnTaskWithoutParametersAsync() { Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(), () => { Assert.ThrowsAsync <Exception>(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync()); }); }
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); }
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)); }