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