public void HasReadableDescription() { string name = "param"; object value = new NamedObject("value"); SetNamedParameterAction action = new SetNamedParameterAction(name, value); AssertDescription.IsEqual(action, "set param=<value>(NMockTests.NamedObject)"); }
public void SetsNamedParameterOnInvocationWrong() { object receiver = new object(); MethodInfoStub methodInfo = new MethodInfoStub("method", new ParameterInfoStub("p1", ParameterAttributes.In), new ParameterInfoStub("p2", ParameterAttributes.Out)); string name = "p2_wrong"; object value = new object(); Invocation invocation = new Invocation(receiver, methodInfo, new object[] { null, null }); SetNamedParameterAction action = new SetNamedParameterAction(name, value); Expect.That(() => ((IAction)action).Invoke(invocation)).Throws <ArgumentException>(new StringContainsMatcher("no such parameter\r\nParameter name: p2_wrong")); }
public void SetsNamedParameterOnInvocation() { object receiver = new object(); MethodInfoStub methodInfo = new MethodInfoStub("method", new ParameterInfoStub("p1", ParameterAttributes.In), new ParameterInfoStub("p2", ParameterAttributes.Out)); string name = "p2"; object value = new object(); Invocation invocation = new Invocation(receiver, methodInfo, new object[] { null, null }); SetNamedParameterAction action = new SetNamedParameterAction(name, value); ((IAction)action).Invoke(invocation); Assert.AreSame(value, invocation.Parameters[1], "set value"); }