protected override void Given() { instance = MockRepository.GenerateStrictMock<TestInterface>(); ar = MockRepository.GenerateStub<IAsyncResult>(); instance.Expect( x => x.BeginMethod( Arg<string>.Is.Equal(parameter), Arg<AsyncCallback>.Is.NotNull, Arg<object>.Is.Null)) .Return(null) .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar)); instance.Expect(x => x.EndMethod(ar)); instance.Expect( x => x.BeginFunction( Arg<string>.Is.Equal(parameter), Arg<AsyncCallback>.Is.NotNull, Arg<object>.Is.Null)) .Return(null) .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar)); instance.Expect(x => x.EndFunction(ar)).Return(result); command = new AsyncPatternCommand(() => instance.Method(parameter)); query = new AsyncPatternQuery<string>(() => instance.Function(parameter)); }
protected override void Given() { instance = MockRepository.GenerateStub<TestInterface>(); instance.Expect( x => x.BeginMethod( Arg<string>.Is.Anything, Arg<AsyncCallback>.Is.Anything, Arg<object>.Is.Anything)) .Return(null) .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null)); instance.Expect(x => x.EndMethod(null)) .Throw(exception); instance.Expect( x => x.BeginFunction( Arg<string>.Is.Anything, Arg<AsyncCallback>.Is.Anything, Arg<object>.Is.Anything)) .Return(null) .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null)); instance.Expect(x => x.EndFunction(null)) .Throw(exception); command = new AsyncPatternCommand(() => instance.Method(null)); query = new AsyncPatternQuery<string>(() => instance.Function(null)); }