Esempio n. 1
0
        private static Core.OngoingStubbing StubMember(MemberExpression member)
        {
            Core.NBehaveMock mock       = ExtractMock(member.Expression);
            string           memberName = "get_" + member.Member.Name;

            return(mock.NBehave.StubMemory.Get(memberName).With());
        }
Esempio n. 2
0
        private static Core.OngoingStubbing StubMethod(MethodCallExpression method)
        {
            Core.NBehaveMock mock       = ExtractMock(method.Object);
            string           methodName = new Internal.MethodNamer(method.Method).Name();

            object[] arguments = new object[method.Arguments.Count];
            for (int i = 0; i < arguments.Length; ++i)
            {
                arguments[i] = Internal.MatcherFactory.Create(method.Arguments[i]);
            }

            return(mock.NBehave.StubMemory.Get(methodName).With(arguments));
        }
Esempio n. 3
0
        /// <summary>
        /// Verify the way in which a method was called. You use this to check if methods should have been called but weren't, if methods were called with the wrong arguments, and so forth.
        /// </summary>
        /// <param name="call">A lambda that always takes no parameters and executes the method you want to verify. See example.</param>
        /// <example>
        /// For more detail, visit the README. Otherwise, all verification statements should look approximately like the below.
        /// <code>
        /// Verify.That(() => mock.Method("hello!")).IsCalled().Once();
        /// </code>
        /// </example>
        public static Core.Verifier That(Expression <Action> call)
        {
            var method = call.Body as MethodCallExpression;

            Core.NBehaveMock mock       = ExtractMock(method.Object);
            string           methodName = new Internal.MethodNamer(method.Method).Name();

            object[] arguments = new object[method.Arguments.Count];
            for (int i = 0; i < arguments.Length; ++i)
            {
                arguments[i] = Internal.MatcherFactory.Create(method.Arguments[i]);
            }

            return(new Internal.Verifier(mock, methodName, new Internal.MatcherList(arguments)));
        }
Esempio n. 4
0
 public Verifier(Core.NBehaveMock mock, string method, Core.MatcherList arguments)
 {
     this.mock      = mock;
     this.method    = method;
     this.arguments = arguments;
 }