public void When_a_registration_made_using_TryRegisterSingle_already_exists_then_TryRegisterSingle_T_does_not_overwrite_it()
        {
            var container = new PocketContainer();

            container.TryRegisterSingle(c => "one");
            container.TryRegisterSingle(c => "two");

            container.Resolve <string>().Should().Be("one");
        }
        public void When_no_registration_exists_then_TryRegisterSingle_registers()
        {
            var container = new PocketContainer();

            container.TryRegisterSingle(typeof(string), c => "one");

            container.Resolve <string>().Should().Be("one");
        }
        public void When_a_registration_made_using_TryRegisterSingle_already_exists_but_has_not_been_resolved_then_TryRegisterSingle_does_not_trigger_its_resolution()
        {
            var container = new PocketContainer();
            var resolved  = false;

            container.RegisterSingle(c =>
            {
                resolved = true;
                return("one");
            });
            container.TryRegisterSingle(typeof(string), c => "two");

            resolved.Should().BeFalse();
        }
        public void When_a_strategy_has_resolved_an_unregistered_type_then_TryRegisterSingle_will_not_overwrite_it()
        {
            var container = new PocketContainer();

            container.AddStrategy(type =>
            {
                if (typeof(string) == type)
                {
                    return(c => "one");
                }

                return(null);
            });

            // trigger the strategy
            container.Resolve <string>();

            container.TryRegisterSingle(typeof(string), c => "two");

            container.Resolve <string>().Should().Be("one");
        }