/// <summary> /// Builds the param expectation. /// </summary> /// <param name="invocation"> /// The invocation. /// </param> /// <param name="method"> /// The method. /// </param> /// <returns> /// </returns> public IExpectation BuildParamExpectation(IInvocation invocation, MethodInfo method) { ArgManager.CheckMethodSignature(method); ConstraintsExpectation expectation = new ConstraintsExpectation(invocation, ArgManager.GetAllConstraints(), new Range(1, null)); expectation.OutRefParams = ArgManager.GetAllReturnValues(); return expectation; }
public ConstraintExpectationTests() { method = typeof (IDemo).GetMethod("VoidThreeArgs"); expectation = new ConstraintsExpectation(new FakeInvocation(this.method), new AbstractConstraint[] { Is.Anything(), Text.Like(@"[\w\d]+"), Is.Equal(3.14f), }, new Range(1, 1)); }
public void CreateErrorMessageForConstraints() { ConstraintsExpectation expectation = new ConstraintsExpectation(new FakeInvocation(this.method), new AbstractConstraint[] { Is.Anything(), Is.Null(), Text.Like(@"[\w\d]+1234") }, new Range(1, 1)); string message = "IDemo.VoidThreeArgs(anything, equal to null, like \"[\\w\\d]+1234\");"; Assert.Equal(message, expectation.ErrorMessage); }
protected override IExpectation GetExpectation(MethodInfo m, Range r, int actual) { IExpectation expectation = new ConstraintsExpectation(new FakeInvocation(m),new AbstractConstraint[0], new Range(1, 1)); SetupExpectation(expectation, r, actual); return expectation; }
public void PassingNullConstraintsThrows() { InvalidOperationException ex = Assert.Throws<InvalidOperationException>( () => expectation = new ConstraintsExpectation(new FakeInvocation(this.method), new AbstractConstraint[] { Is.Anything(), null, Is.Equal(3.14f), }, new Range(1, 1))); Assert.Equal("The constraint at index 1 is null! Use Is.Null() to represent null parameters.", ex.Message); }