Exemple #1
0
 public RecordingCallRule(FakeManager fakeManager, RecordedCallRule recordedRule, FakeAsserter.Factory asserterFactory, IFakeObjectCallFormatter callFormatter)
 {
     this.fakeManager     = fakeManager;
     this.recordedRule    = recordedRule;
     this.asserterFactory = asserterFactory;
     this.callFormatter   = callFormatter;
 }
Exemple #2
0
        public void SetUp()
        {
            this.fake = Fake.GetFakeObject(ServiceLocator.Current.Resolve <FakeObjectFactory>().CreateFake(typeof(IFoo), null, false));

            this.fakeAsserter = A.Fake <FakeAsserter>();

            this.matcher = A.Fake <ExpressionCallMatcher>(() =>
                                                          new ExpressionCallMatcher(
                                                              ExpressionHelper.CreateExpression <IFoo>(x => Console.WriteLine("")),
                                                              ServiceLocator.Current.Resolve <ArgumentValidatorFactory>(),
                                                              ServiceLocator.Current.Resolve <MethodInfoManager>()));

            this.callMatcherFactory = A.Fake <IExpressionCallMatcherFactory>();
            A.CallTo(() => this.callMatcherFactory.CreateCallMathcer(A <LambdaExpression> .Ignored)).Returns(() => this.matcher);

            this.fakeAsserterFactory = x =>
            {
                this.argumentToFakeAsserterFactory = x;
                return(this.fakeAsserter);
            };

            this.assertions = new FakeAssertions <IFoo>(this.fake, this.callMatcherFactory, this.fakeAsserterFactory);

            this.FakedFoo.Bar();
            this.FakedFoo.Baz();
        }
        public void SetUp()
        {
            this.fake = Fake.GetFakeManager(A.Fake<IFoo>());
            
            this.fakeAsserter = A.Fake<IFakeAsserter>();
            
            this.matcher = A.Fake<ExpressionCallMatcher>(x => x.WithArgumentsForConstructor(() =>
                new ExpressionCallMatcher(
                    ExpressionHelper.CreateExpression<IFoo>(_ => Console.WriteLine("")),
                    ServiceLocator.Current.Resolve<ArgumentConstraintFactory>(),
                    ServiceLocator.Current.Resolve<MethodInfoManager>())));

            this.callMatcherFactory = A.Fake<IExpressionCallMatcherFactory>();
            A.CallTo(() => this.callMatcherFactory.CreateCallMathcer(A<LambdaExpression>.Ignored)).ReturnsLazily(x => this.matcher);

            this.fakeAsserterFactory = x =>
                {
                    this.argumentToFakeAsserterFactory = x;
                    return this.fakeAsserter;
                };

            this.assertions = new FakeAssertions<IFoo>(this.fake, this.callMatcherFactory, this.fakeAsserterFactory);

            this.FakedFoo.Bar();
            this.FakedFoo.Baz();
        }
Exemple #4
0
        public void SetUp()
        {
            this.fake = new FakeObject(typeof(IFoo));

            this.fakeAsserter = A.Fake <FakeAsserter>(() => new FakeAsserter(new List <IFakeObjectCall>()));

            this.matcher = A.Fake <ExpressionCallMatcher>(() =>
                                                          new ExpressionCallMatcher(
                                                              ExpressionHelper.CreateExpression <IFoo>(x => Console.WriteLine("")),
                                                              ServiceLocator.Current.Resolve <ArgumentValidatorFactory>(),
                                                              ServiceLocator.Current.Resolve <MethodInfoManager>()));

            this.callMatcherFactory = x =>
            {
                this.argumentToCallMatcherFactory = x;
                return(this.matcher);
            };

            this.fakeAsserterFactory = x =>
            {
                this.argumentToFakeAsserterFactory = x;
                return(this.fakeAsserter);
            };

            this.assertions = new FakeAssertions <IFoo>(this.fake, this.callMatcherFactory, this.fakeAsserterFactory);

            this.FakedFoo.Bar();
            this.FakedFoo.Baz();
        }
Exemple #5
0
        public void SetUp()
        {
            this.fake = Fake.GetFakeManager(A.Fake <IFoo>());

            this.fakeAsserter = A.Fake <IFakeAsserter>();

            this.matcher = A.Fake <ExpressionCallMatcher>(x => x.WithArgumentsForConstructor(() =>
                                                                                             new ExpressionCallMatcher(
                                                                                                 ExpressionHelper.CreateExpression <IFoo>(_ => Console.WriteLine("")),
                                                                                                 ServiceLocator.Current.Resolve <ArgumentConstraintFactory>(),
                                                                                                 ServiceLocator.Current.Resolve <MethodInfoManager>())));

            this.callMatcherFactory = A.Fake <IExpressionCallMatcherFactory>();
            A.CallTo(() => this.callMatcherFactory.CreateCallMathcer(A <LambdaExpression> .Ignored)).ReturnsLazily(x => this.matcher);

            this.fakeAsserterFactory = x =>
            {
                this.argumentToFakeAsserterFactory = x;
                return(this.fakeAsserter);
            };

            this.assertions = new FakeAssertions <IFoo>(this.fake, this.callMatcherFactory, this.fakeAsserterFactory);

            this.FakedFoo.Bar();
            this.FakedFoo.Baz();
        }
        private static IDisposable SetOrderedFactoryAsCurrentAndGetResetter(OrderedFakeAsserterFactory orderedFactory)
        {
            var resetter = new AsserterResetter { ResetTo = currentAsserterFactoryField };

            currentAsserterFactoryField = orderedFactory.CreateAsserter;

            return resetter;
        }
        internal RuleBuilder(BuildableCallRule ruleBeingBuilt, FakeObject fakeObject, FakeAsserter.Factory asserterFactory)
        {
            Debug.Assert(fakeObject != null);

            this.RuleBeingBuilt  = ruleBeingBuilt;
            this.fakeObject      = fakeObject;
            this.asserterFactory = asserterFactory;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeAsserter&lt;TFake&gt;"/> class.
        /// </summary>
        /// <param name="fake">The fake.</param>
        public FakeAssertions(FakeObject fake, IExpressionCallMatcherFactory callMatcherFactory, FakeAsserter.Factory fakeAsserterFactory)
        {
            Guard.IsNotNull(fake, "fake");
            Guard.IsNotNull(callMatcherFactory, "callMatcherFactory");
            Guard.IsNotNull(fakeAsserterFactory, "fakeAsserterFactory");

            this.callMatcherFactory  = callMatcherFactory;
            this.fakeAsserterFactory = fakeAsserterFactory;
            this.fake = fake;
        }
        private static IDisposable SetOrderedFactoryAsCurrentAndGetResetter(OrderedFakeAsserterFactory orderedFactory)
        {
            var resetter = new AsserterResetter {
                ResetTo = currentAsserterFactoryField
            };

            currentAsserterFactoryField = orderedFactory.CreateAsserter;

            return(resetter);
        }
Exemple #10
0
        public void SetUp()
        {
            this.fakedObject  = A.Fake <IFoo>();
            this.fakeObject   = Fake.GetFakeObject(fakedObject);
            this.recordedRule = A.Fake <RecordedCallRule>(x => x.WithArgumentsForConstructor(() => new RecordedCallRule(A.Fake <MethodInfoManager>())));

            this.asserter = A.Fake <FakeAsserter>();

            this.asserterFactory = x =>
            {
                this.argumentUsedForAsserterFactory = x;
                return(this.asserter);
            };
        }
Exemple #11
0
        public void SetUp()
        {
            this.fakedObject  = A.Fake <IFoo>();
            this.fakeObject   = Fake.GetFakeObject(fakedObject);
            this.recordedRule = A.Fake <RecordedCallRule>(() => new RecordedCallRule(A.Fake <MethodInfoManager>()));

            this.asserter = A.Fake <FakeAsserter>(() => new FakeAsserter(Enumerable.Empty <IFakeObjectCall>()));

            this.asserterFactory = x =>
            {
                this.argumentUsedForAsserterFactory = x;
                return(this.asserter);
            };
        }
        public void Setup()
        {
            this.fakedObject = A.Fake<IFoo>();
            this.fakeObject = Fake.GetFakeManager(this.fakedObject);
            this.recordedRule = A.Fake<RecordedCallRule>(x => x.WithArgumentsForConstructor(() => new RecordedCallRule(A.Fake<MethodInfoManager>())));
            this.callFormatter = A.Fake<IFakeObjectCallFormatter>();

            this.asserter = A.Fake<IFakeAsserter>();

            this.asserterFactory = x =>
                {
                    this.argumentUsedForAsserterFactory = x;
                    return this.asserter;
                };
        }
Exemple #13
0
 internal RuleBuilder(BuildableCallRule ruleBeingBuilt, FakeManager manager, FakeAsserter.Factory asserterFactory)
 {
     this.RuleBeingBuilt  = ruleBeingBuilt;
     this.manager         = manager;
     this.asserterFactory = asserterFactory;
 }
Exemple #14
0
 public RecordingCallRule(FakeObject fakeObject, RecordedCallRule recordedRule, FakeAsserter.Factory asserterFactory)
 {
     this.fakeObject      = fakeObject;
     this.recordedRule    = recordedRule;
     this.asserterFactory = asserterFactory;
 }