c# Moq Ref/out 参数

        public interface IService
        {
            void DoSomething(ref string a);
            void DoSomething2(out string a);
        }
    

        [TestMethod]
        public void TestRefPara()
        {
            var service = new Mock<IService>();
            service.Setup(s => s.DoSomething(ref It.Ref<string>.IsAny));
            string actualValue= "value";
            service.Object.DoSomething(ref actualValue);
            Assert.AreEqual("value", actualValue);
        }

        [TestMethod]
        public void TestOutPara()
        {
            var service = new Mock<IService>();
            string outPara = "abc"; 
            string actualValue = "value";
            service.Setup(s => s.DoSomething2(out outPara)); 
            service.Object.DoSomething2(out actualValue);
            Assert.AreEqual("abc", actualValue);
        }

  

fffffffffffffffff
test red font.
原文地址:https://www.cnblogs.com/wgscd/p/14867881.html