public void TrapsExceptionsWhenInvokedOnAnotherObject() { Exception exception = new Exception("thrown from Foo"); invocation = new Invocation(receiver, FOO_METHOD, new object[] { "input", null }); MockFoo mockFoo = new MockFoo(); mockFoo.Foo_ExpectedInput = "input"; mockFoo.Foo_Exception = exception; invocation.InvokeOn(mockFoo); Assert.IsTrue(mockFoo.FooWasInvoked, "Foo should have been invoked"); Assert.AreSame(exception, invocation.Exception, "exception"); }
public async Task Validate_Address_Ok() { var foo = new MockFoo(); var cut = Context.RenderComponent <ValidateForm>(pb => { pb.Add(a => a.Model, foo); pb.AddChildContent <MockInput <string> >(pb => { pb.Add(a => a.Value, foo.Address); pb.Add(a => a.ValueExpression, Utility.GenerateValueExpression(foo, "Address", typeof(string))); }); }); var form = cut.Find("form"); await cut.InvokeAsync(() => form.Submit()); var msg = cut.FindComponent <MockInput <string> >().Instance.GetErrorMessage(); Assert.Equal("Address must fill", msg); }
public void CanBeInvokedOnAnotherObject() { string input = "INPUT"; string output = "OUTPUT"; string result = "RESULT"; invocation = new Invocation(receiver, FOO_METHOD, new object[] { input, null }); MockFoo mockFoo = new MockFoo(); mockFoo.Foo_ExpectedInput = input; mockFoo.Foo_Output = output; mockFoo.Foo_Result = result; invocation.InvokeOn(mockFoo); Assert.IsTrue(mockFoo.FooWasInvoked, "Foo should have been invoked"); Assert.AreEqual(invocation.Result, result, "result"); Assert.AreEqual(invocation.Parameters[1], output, "output"); }
public void SetUp() { receiver = new object(); target = new MockFoo(); next = new MockInvokable(); invoker = new Invoker(typeof (IFoo), target, next); }
public void TrapsExceptionsWhenInvokedOnAnotherObject() { var exception = new Exception("thrown from Foo"); invocation = new Invocation(receiver, FOO_METHOD, new object[] {"input", null}); var mockFoo = new MockFoo(); mockFoo.Foo_ExpectedInput = "input"; mockFoo.Foo_Exception = exception; invocation.InvokeOn(mockFoo); Assert.IsTrue(mockFoo.FooWasInvoked, "Foo should have been invoked"); Assert.AreSame(exception, invocation.Exception, "exception"); }
public void CanBeInvokedOnAnotherObject() { string input = "INPUT"; string output = "OUTPUT"; string result = "RESULT"; invocation = new Invocation(receiver, FOO_METHOD, new object[] {input, null}); var mockFoo = new MockFoo(); mockFoo.Foo_ExpectedInput = input; mockFoo.Foo_Output = output; mockFoo.Foo_Result = result; invocation.InvokeOn(mockFoo); Assert.IsTrue(mockFoo.FooWasInvoked, "Foo should have been invoked"); Assert.AreEqual(invocation.Result, result, "result"); Assert.AreEqual(invocation.Parameters[1], output, "output"); }