public void Should_create_instance_of_registered_type()
        {
            var sut = new TestFixtureFactory(typeof(object));

            var instance = sut.Create().Fixture;

            Assert.NotNull(instance);
            Assert.IsType<object>(instance);
        }
        public void Should_create_instance_of_registered_type_with_constructor_parameters_by_passing_context_to_lambda()
        {
            var sut = new TestFixtureFactory(typeof(TypeWithConstructorParameters));
            sut.Configure(() => new object());

            var instance = sut.Create().Fixture as TypeWithConstructorParameters;

            Assert.NotNull(instance);
            Assert.NotNull(instance.ConstructorParameter);
        }
        public void Should_reuse_created_instances_of_same_type_in_object_graph()
        {
            var sut = new TestFixtureFactory(typeof(A));
            sut.Configure(f => new B(f.Create(typeof(object))));
            sut.Configure(f => new C(f.Create(typeof(object))));
            sut.Configure(() => new object());

            var instance = (A)sut.Create().Fixture;

            Assert.Same(instance.B.O, instance.C.O);
        }
            protected override ITestFixtureFactory GetFactory(Type type)
            {
                var testFixtureFactory = new TestFixtureFactory(type);

                testFixtureFactory.Configure(x => new DependencyA(
                                                 (DependencyB)x.Create(typeof(DependencyB)),
                                                 (DependencyC)x.Create(typeof(DependencyC))));
                testFixtureFactory.Configure(() => new DependencyB());
                testFixtureFactory.Configure(() => new DependencyC());

                return(testFixtureFactory);
            }
        public void Should_dispose_disposables_when_fixture_scope_is_disposed()
        {
            var sut = new TestFixtureFactory(typeof(A));
            sut.Configure(f => new B(f.Create(typeof(object))));
            sut.Configure(f => new C(f.Create(typeof(object))));
            sut.Configure(() => new object());

            var scope = sut.Create();

            scope.Dispose();
            var fixture = scope.Fixture as A;
            Assert.True(fixture.C.WasDisposed);
        }