コード例 #1
0
        public void Container_registrations_can_be_iterated()
        {
            var container = new PocketContainer();

            container.Count().Should().BeGreaterThan(1);
            container.Select(r => r.Key).Should().Contain(typeof(PocketContainer));
        }
コード例 #2
0
        public void When_a_strategy_on_the_clone_results_in_a_new_registration_then_the_original_contanier_is_not_affected()
        {
            var original = new PocketContainer();
            var clone    = original.Clone().AutoMockInterfacesAndAbstractClasses();

            clone.Resolve <IEnumerable <string> >();

            original.Count().Should().Be(clone.Count() - 1);
        }
        public void Lazy_registrations_in_the_override_do_not_modify_the_parent()
        {
            var primary = new PocketContainer();

            var @override = primary.CreateOverrideContainer();

            primary.Register(c => "from primary");

            @override.Resolve <HasDefaultCtor>();

            primary.Count(reg => reg.Key == typeof(HasDefaultCtor)).Should().Be(0);
        }
コード例 #4
0
        public void When_a_strategy_on_the_clone_results_in_a_new_registration_then_the_original_contanier_is_not_affected()
        {
            var original = new PocketContainer();
            var clone    = original
                           .Register(c => new List <string>())
                           .Clone()
                           .RegisterGeneric(typeof(IEnumerable <>), to: typeof(List <>));

            clone.Resolve <IEnumerable <string> >();

            original.Count().Should().Be(clone.Count() - 1);
        }
コード例 #5
0
        public void When_a_strategy_on_the_clone_results_in_a_new_registration_then_the_original_contanier_is_not_affected()
        {
            var original = new PocketContainer();
            var clone = original.Clone().AutoMockInterfacesAndAbstractClasses();

            clone.Resolve<IEnumerable<string>>();

            original.Count().Should().Be(clone.Count() - 1);
        }
        public void Lazy_registrations_in_the_override_do_not_modify_the_parent()
        {
            var primary = new PocketContainer();

            var @override = primary.CreateOverrideContainer();
            primary.Register(c => "from primary");

            @override.Resolve<HasDefaultCtor>();

            primary.Count(reg => reg.Key == typeof (HasDefaultCtor)).Should().Be(0);
        }