public void Should_return_original_registration_by_type() { var builder = new ContainerBuilder(); builder.RegisterCodeSwitchDisabled<UseClassAv2>(); builder.RegisterSwitchedType<UseClassAv2, A, ClassA_V2, ClassA>(); IContainer container = builder.Build(); var a = container.Resolve<A>(); Assert.IsInstanceOf<ClassA>(a); }
public void Should_use_the_old_methods() { var builder = new ContainerBuilder(); builder.RegisterCodeSwitchDisabled<UseNewMethod>(); builder.RegisterType<ConditionalClass>(); var container = builder.Build(); var conditionalClass = container.Resolve<ConditionalClass>(); Assert.AreEqual("Old: 42, Test", conditionalClass.FunctionCall(42, "Test")); }
public void Should_be_able_to_enable_a_fooid_after_creation() { var builder = new ContainerBuilder(); builder.RegisterCodeSwitchDisabled<UseNewMethod>(); builder.RegisterType<ConditionalClass>(); var container = builder.Build(); var conditionalClass = container.Resolve<ConditionalClass>(); Assert.AreEqual("Old: 42, Test", conditionalClass.FunctionCall(42, "Test")); container.EnableCodeSwitch<UseNewMethod>(); conditionalClass = container.Resolve<ConditionalClass>(); Assert.AreEqual("V2: 42, Test", conditionalClass.FunctionCall(42, "Test")); }