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

            Assert.AreSame(invocationInterceptor, MockInvocationInterceptor.GetFromTarget(target));
        }
Esempio 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);
        }
Esempio 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));
        }
Esempio 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()));
 }