public void HandlingOutParametersInStubs() { // Create a stub. ISampleClass stub = CreateStub(); // Here's how you stub an "out" parameter. The "Dummy" part is // just to satisfy the compiler. stub.Stub(s => s.MethodWithOutParameter(out Arg <int> .Out(10).Dummy)); // Call method with out parameters. int i; stub.MethodWithOutParameter(out i); i.Should(Be.EqualTo(10)); }
public void HandlingOutParametersInStubs() { // Create a stub. ISampleClass stub = CreateStub(); // Here's how you stub an "out" parameter. int outi; stub.WhenForAnyArgs(s => s.MethodWithOutParameter(out outi)).Do(x => x[0] = 10); // Call method with out parameters. int i; stub.MethodWithOutParameter(out i); i.Should(Be.EqualTo(10)); }
public void HandlingOutParametersInStubs() { // Create a stub. ISampleClass stub = CreateStub(); Mock <ISampleClass> stubClass = Mock.Get(stub); // Here's how you stub an "out" parameter. var outi = 10; stubClass.Setup(s => s.MethodWithOutParameter(out outi)); // Call method with out parameters. int i; stub.MethodWithOutParameter(out i); i.Should(Be.EqualTo(10)); }
public void YouCanCreateStubByCallingMockRepositoryGenerateStub() { // Create a stub. ISampleClass stub = CreateStub(); // Ensure that its string property is null or empty. stub.Property.Should(Be.Null.Or.Empty); int outparam; string refparam = "test"; // Call some methods. stub.VoidMethod(); stub.MethodThatReturnsInteger("test").Should(Be.EqualTo(0)); stub.MethodThatReturnsObject(0).Should(Be.Null); stub.MethodWithOutParameter(out outparam); outparam.Should(Be.EqualTo(0)); stub.MethodWithRefParameter(ref refparam); refparam.Should(Be.EqualTo("test")); }