public void When_a_registration_made_using_TryRegister_already_exists_then_TryRegister_does_not_overwrite_it() { var container = new PocketContainer(); container.TryRegister(c => "one"); container.TryRegister(typeof(string), c => "two"); container.Resolve <string>().Should().Be("one"); }
public void When_no_registration_exists_then_TryRegister_T_registers() { var container = new PocketContainer(); container.TryRegister(c => "one"); container.Resolve <string>().Should().Be("one"); }
public void When_a_strategy_has_resolved_an_unregistered_type_then_TryRegister_T_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.TryRegister(c => "two"); container.Resolve <string>().Should().Be("one"); }