示例#1
0
    public void TestReturnsWithTestMethodOutParameter()
    {
        var originalResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _);
        var expectedResult = 2;

        Mock.Setup(
            typeof(TestStaticClass),
            nameof(TestStaticClass.TestMethodReturn1WithOutParameter),
            () =>
        {
            var actualResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _);

            Assert.AreNotEqual(originalResult, actualResult);
            Assert.AreEqual(expectedResult, actualResult);
        })
        .Returns(expectedResult);
    }
示例#2
0
    public void TestGenericSetupReturnsWithTestMethodOutParameter()
    {
        var originalResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _);
        var expectedResult = 2;

        var x = 1;

        Mock.Setup(
            () => TestStaticClass.TestMethodReturn1WithOutParameter(out x),
            () =>
        {
            var actualResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _);

            Assert.AreNotEqual(originalResult, actualResult);
            Assert.AreEqual(expectedResult, actualResult);
        })
        .Returns(expectedResult);
    }