public static void SpecifyReturnsAndAssignOutAndRefParameterForNonVoidDelegate( NonVoidDelegateWithOutAndRefParameters subject, int refValue, int outValue, Foo expectedResult, Foo result) { "Given a faked delegate with a non-void return type and ref and out parameters" .x(() => subject = A.Fake <NonVoidDelegateWithOutAndRefParameters>()); "When the faked delegate is configured to return a value and assign the out and ref parameters" .x(() => { expectedResult = new Foo(); A.CallTo(() => subject(1, ref refValue, out outValue)).Returns(expectedResult).AssignsOutAndRefParameters(42, 99); }); "And I call the faked delegate" .x(() => result = subject(1, ref refValue, out outValue)); "Then it returns the specified value" .x(() => result.Should().BeSameAs(expectedResult)); "And the ref parameter is set to the specified value" .x(() => refValue.Should().Be(42)); "And the out parameter is set to the specified value" .x(() => outValue.Should().Be(99)); }
public static void AssignOutAndRefParameterForNonVoidDelegate( NonVoidDelegateWithOutAndRefParameters subject, int refValue, int outValue, Foo result) { "Given a faked delegate with a non-void return type and ref and out parameters" .x(() => subject = A.Fake <NonVoidDelegateWithOutAndRefParameters>()); "When the faked delegate is configured to assign the out and ref parameters without setting the return value" .x(() => A.CallTo(() => subject(1, ref refValue, out outValue)) .AssignsOutAndRefParameters(43, 100)); "And I call the faked delegate" .x(() => result = subject(1, ref refValue, out outValue)); "Then it returns a Dummy value" .x(() => result.Should().BeSameAs(FooFactory.Instance)); "And the ref parameter is set to the specified value" .x(() => refValue.Should().Be(43)); "And the out parameter is set to the specified value" .x(() => outValue.Should().Be(100)); }
public static void AssignOutAndRefParameterForNonVoidDelegate( NonVoidDelegateWithOutAndRefParameters subject, int refValue, int outValue, int result) { "Given a faked delegate with a non-void return type and ref and out parameters" .x(() => subject = A.Fake<NonVoidDelegateWithOutAndRefParameters>()); "When the faked delegate is configured to assign the out and ref parameters" .x(() => A.CallTo(() => subject(1, ref refValue, out outValue)) .Returns(123).AssignsOutAndRefParameters(42, 99)); "And I call the faked delegate" .x(() => result = subject(1, ref refValue, out outValue)); "Then it returns the specified value" .x(() => result.Should().Be(123)); "And the ref parameter is set to the specified value" .x(() => refValue.Should().Be(42)); "And the out parameter is set to the specified value" .x(() => outValue.Should().Be(99)); }