示例#1
0
        public void NotExpiredExpectationYieldsIsExpiredTrue()
        {
            Expression <Func <ForTestingPurposes, string> > expression = s => s.MethodCall(0, "zero");
            var expiration = While.Result.True <object>((i, dt) => true);

            var expectation = Expectation.FromMethodCallExpression(expression.Body as MethodCallExpression, expiration);

            Assert.False(expectation.IsExpired(null, DateTime.UtcNow));
        }
示例#2
0
        public void ReturnTypeMismatchYieldsNoHit()
        {
            Expression <Func <ForTestingPurposes, string> > expression = s => s.MethodCall(0, "zero");
            var expiration = While.Result.True <object>((i, dt) => true);

            var expectation = Expectation.FromMethodCallExpression(expression.Body as MethodCallExpression, expiration);

            var invocation = new Mock <Castle.DynamicProxy.IInvocation>(MockBehavior.Strict);
            var methodInfo = new Mock <MethodInfo>(MockBehavior.Strict);

            methodInfo.Setup(x => x.Name).Returns("MethodCall");
            methodInfo.Setup(x => x.ReturnType).Returns(typeof(int));

            invocation.Setup(x => x.Method).Returns(methodInfo.Object);
            invocation.Setup(x => x.Arguments).Returns(new object[] { 0, "zero" });

            Assert.False(expectation.IsHit(invocation.Object));
        }