Exemplo n.º 1
0
 /// <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);
     var expectation = new ConstraintsExpectation(invocation, ArgManager.GetAllConstraints(), new Range(1, null));
     expectation.OutRefParams = ArgManager.GetAllReturnValues();
     return expectation;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Determines if the object equal to expectation
        /// </summary>
        public override bool Equals(object obj)
        {
            ConstraintsExpectation other = obj as ConstraintsExpectation;

            if (other == null)
            {
                return(false);
            }
            return(Method.Equals(other.Method) && Validate.ArgsEqual(constraints, other.constraints));
        }
 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.AreEqual(message, expectation.ErrorMessage);
 }
		public void PassingNullConstraintsThrows()
		{
			Assert.Throws<InvalidOperationException>(
				"The constraint at index 1 is null! Use Is.Null() to represent null parameters.",
				() =>
				expectation = new ConstraintsExpectation(new FakeInvocation(this.method), new AbstractConstraint[]
				{
					Is.Anything(),
					null,
					Is.Equal(3.14f),
				}, new Range(1, 1)));
		}
 public void PassingNullConstraintsThrows()
 {
     expectation = new ConstraintsExpectation(new FakeInvocation(this.method), new AbstractConstraint[]
         {
             Is.Anything(),
             null,
             Is.Equal(3.14f),
     }, new Range(1, 1));
 }
 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;
 }