public void GetFromTarget()
        {
            var invocationInterceptor = new MockInvocationInterceptor(new TestExpectationScope());
            var target = new Target(invocationInterceptor);

            Assert.AreSame(invocationInterceptor, MockInvocationInterceptor.GetFromTarget(target));
        }
Ejemplo n.º 2
0
        static Expectation CreateExpectation(InvocationMatcher invocationMatcher, NumberOfInvocationsConstraint numberOfInvocationsConstraint, bool hasHigherPrecedence)
        {
            var expectation = new Expectation(invocationMatcher, numberOfInvocationsConstraint);

            MockInvocationInterceptor.GetFromTarget(invocationMatcher.Target).AddExpectation(expectation, hasHigherPrecedence);

            return(expectation);
        }
Ejemplo n.º 3
0
        IAssertInvocations Assert(InvocationMatcher invocationMatcher)
        {
            var invocationHistory = MockInvocationInterceptor.GetFromTarget(invocationMatcher.Target).ExpectationScope.InvocationHistory;
            var matchingInvocations = invocationHistory.Invocations.Where(invocationMatcher.Matches).ToArray();

            if (!numberOfInvocationsConstraint.Matches(matchingInvocations.Length))
                throw new ExpectationsException(invocationHistory, "Wrong number of invocations for '{0}', expected {1} actual {2}:", invocationMatcher, numberOfInvocationsConstraint, matchingInvocations.Length);
       
            return new AssertInvocations(new MatchedInvocations(previousMatch, numberOfInvocationsConstraint, invocationMatcher, matchingInvocations));
        }
Ejemplo n.º 4
0
        public static void MatchingExpectationsFor(object target)
        {
            var mockInvocationInterceptor = MockInvocationInterceptor.GetFromTarget(target);

            AssertExpectationScopeIsMet(mockInvocationInterceptor.ExpectationScope);
        }
 public void GetFromTargetProxyWithNonMockInvocationInterceptor()
 {
     Assert.Throws <ArgumentException>(() => MockInvocationInterceptor.GetFromTarget(new Target(new OtherInvocationInterceptor())));
 }
 public void GetFromTargetNonProxy()
 {
     Assert.Throws <ArgumentException>(() => MockInvocationInterceptor.GetFromTarget(new object()));
 }