/// <summary> /// Creates a new <see cref="AbstractExpectation"/> instance. /// </summary> /// <param name="invocation">The originalInvocation for this method, required because it contains the generic type infromation</param> /// <param name="expectedRange">Number of method calls for this expectations</param> protected AbstractExpectation(IInvocation invocation, Range expectedRange) { Validate.IsNotNull(invocation, "originalInvocation"); Validate.IsNotNull(invocation.Method, "method"); this.originalInvocation = invocation; this.method = invocation.Method; this.expected = expectedRange; }
/// <summary> /// Creates a new <see cref="AbstractExpectation"/> instance. /// </summary> /// <param name="expectation">Expectation.</param> protected AbstractExpectation(IExpectation expectation) : this(expectation.Originalinvocation, new Range(1, 1)) { returnValue = expectation.ReturnValue; returnValueSet = expectation.HasReturnValue; expected = expectation.Expected; actualCallsCount = expectation.ActualCallsCount; repeatableOption = expectation.RepeatableOption; exceptionToThrow = expectation.ExceptionToThrow; message = expectation.Message; actionToExecute = expectation.ActionToExecute; outRefParams = expectation.OutRefParams; allowTentativeReturn = expectation.AllowTentativeReturn; }
/// <summary> /// Creates a new <see cref="ArgsEqualExpectation"/> instance. /// </summary> /// <param name="expectedArgs">Expected args.</param> /// <param name="invocation">The invocation for this expectation</param> /// <param name="expectedRange">Number of method calls for this expectations</param> public ArgsEqualExpectation(IInvocation invocation, object[] expectedArgs, Range expectedRange) : base(invocation, expectedRange) { this.expectedArgs = expectedArgs; }
public void RangeToStringWhenMinZeroAndMaxNonZero() { Range range = new Range(0, 30); Assert.AreEqual("30", range.ToString()); }
public void RangeToStringWhenMinMaxEqual() { Range range = new Range(30, 30); Assert.AreEqual("30", range.ToString()); }
public void RangeToString() { Range range = new Range(30, 50); Assert.AreEqual("30..50", range.ToString()); }
public void RangePropetiesReturnTheSameValuesAsThosePassedInCtor() { Range range = new Range(30, 50); Assert.AreEqual(30, range.Min); Assert.AreEqual(50, range.Max); }
/// <summary> /// Creates a new <see cref="CallbackExpectation"/> instance. /// </summary> /// <param name="invocation">Invocation for this expectation</param> /// <param name="callback">Callback.</param> /// <param name="expectedRange">Number of method calls for this expectations</param> public CallbackExpectation(IInvocation invocation, Delegate callback, Range expectedRange) : base(invocation, expectedRange) { this.callback = callback; ValidateCallback(); }
/// <summary> /// Creates a new <see cref="ConstraintsExpectation"/> instance. /// </summary> /// <param name="invocation">Invocation for this expectation</param> /// <param name="constraints">Constraints.</param> /// <param name="expectedRange">Number of method calls for this expectations</param> public ConstraintsExpectation(IInvocation invocation, AbstractConstraint[] constraints, Range expectedRange) : base(invocation, expectedRange) { Validate.IsNotNull(constraints, "constraints"); this.constraints = constraints; ConstraintsMatchMethod(); }