Ejemplo n.º 1
0
        public void CallsTo_with_function_call_should_add_expression_rule()
        {
            var expression = CreateExpression <IFoo, int>(x => x.Baz());

            configuration.CallsTo(expression);

            Assert.That(this.fake.Rules.Any(x => x.Equals(this.ruleProducedByFactory)), Is.True);
        }
Ejemplo n.º 2
0
        public void CallsTo_with_function_call_should_add_expression_interceptor_to_fake_object()
        {
            var expression = CreateExpression <IFoo, int>(x => x.Baz());

            configuration.CallsTo(expression);


            Assert.That(expression, WasAddedToFake(this.fake));
        }
Ejemplo n.º 3
0
        public void Calls_configured_in_a_child_context_does_not_exist_outside_that_context()
        {
            var fake   = new FakeObject(typeof(IFoo));
            var config = new FakeConfiguration <IFoo>(fake);

            using (Fake.CreateScope())
            {
                config.CallsTo(x => x.Baz()).Returns(10);
            }

            Assert.That(((IFoo)fake.Object).Baz(), Is.Not.EqualTo(10));
        }
Ejemplo n.º 4
0
        public void Return_value_can_be_read_back_from_recorded_calls()
        {
            var fake = new FakeObject(typeof(IFoo));
            var foo  = (IFoo)fake.Object;

            var config = new FakeConfiguration <IFoo>(fake);

            config.CallsTo(x => x.Baz()).Returns(10);

            foo.Baz();

            Assert.That(fake.RecordedCallsInScope.Single().ReturnValue, Is.EqualTo(10));
        }