Пример #1
0
        public ExpectationExpression <TController> For <TController>()
        {
            var expression = new ExpectationExpression <TController>();

            _expectationsExpressions.Add(expression);
            return(expression);
        }
Пример #2
0
        public ExpectationExpression <TController> For <TController>(Expression <Func <TController, object> > actionExpression)
        {
            var expression = new ExpectationExpression <TController>(actionExpression);

            _expectationsExpressions.Add(expression);
            return(expression);
        }
        private static IEnumerable <ExpectationGroup> CreateExpectationGroupsFor(ExpectationExpression expectationExpression)
        {
            var groups = new List <ExpectationGroup>();

            if (String.IsNullOrEmpty(expectationExpression.Action))
            {
                var actionMethods = expectationExpression.Controller.GetActionMethods();
                foreach (var expectationGroup in actionMethods.Select(actionMethod => new ExpectationGroup(expectationExpression.Controller, actionMethod.GetActionName())))
                {
                    expectationExpression.Expectations.Each(expectationGroup.ApplyExpectation);
                    groups.Add(expectationGroup);
                }
            }
            else
            {
                var expectationGroup = new ExpectationGroup(expectationExpression.Controller, expectationExpression.Action);
                expectationExpression.Expectations.Each(expectationGroup.ApplyExpectation);
                groups.Add(expectationGroup);
            }

            return(groups);
        }
        private static IEnumerable <ExpectationGroup> GetMatchingExpectationGroups(IEnumerable <ExpectationGroup> expectations, ExpectationExpression expectationExpression)
        {
            if (String.IsNullOrEmpty(expectationExpression.Action))
            {
                return(expectations.Where(expectation =>
                                          expectation.Controller == expectationExpression.Controller
                                          ));
            }

            return(expectations.Where(expectation =>
                                      expectation.Action == expectationExpression.Action &&
                                      expectation.Controller == expectationExpression.Controller
                                      ));
        }
Пример #5
0
 public static ExpectationExpression Has <TSecurityPolicy>(this ExpectationExpression expectationExpression) where TSecurityPolicy : class, ISecurityPolicy
 {
     return(expectationExpression.Add(new HasTypeExpectation <TSecurityPolicy>()));
 }
Пример #6
0
 public static ExpectationExpression DoesNotHave <TSecurityPolicy>(this ExpectationExpression expectationExpression, TSecurityPolicy instance) where TSecurityPolicy : ISecurityPolicy
 {
     return(expectationExpression.Add(new DoesNotHaveInstanceExpectation(instance)));
 }
Пример #7
0
 public static ExpectationExpression DoesNotHave <TSecurityPolicy>(this ExpectationExpression expectationExpression, Expression <Func <TSecurityPolicy, bool> > predicate) where TSecurityPolicy : class, ISecurityPolicy
 {
     return(expectationExpression.Add(new DoesNotHaveTypeExpectation <TSecurityPolicy>(predicate)));
 }
Пример #8
0
 public static ExpectationExpression DoesNotHave <TSecurityPolicy>(this ExpectationExpression expectationExpression) where TSecurityPolicy : class, ISecurityPolicy
 {
     return(expectationExpression.Add(new DoesNotHaveTypeExpectation <TSecurityPolicy>()));
 }
Пример #9
0
 public static ExpectationExpression Has <TSecurityPolicy>(this ExpectationExpression expectationExpression, TSecurityPolicy instance) where TSecurityPolicy : ISecurityPolicy
 {
     return(expectationExpression.Add(new HasInstanceExpectation(instance)));
 }