Exemplo n.º 1
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();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
        }