public void should_add_always() { var scanner = new DefaultConventionScanner { Overwrites = OverwriteBehavior.Always }; var services = new ServiceRegistry(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services.AddTransient <IWidget, BWidget>(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services.AddTransient <IWidget>(x => new AWidget()); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services.AddTransient <IWidget, AWidget>(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); }
public void should_add_with_overwrite_if_newer() { var scanner = new DefaultConventionScanner { Overwrites = OverwriteBehavior.NewType }; var services = new ServiceRegistry(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services.AddTransient <IWidget, BWidget>(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services = new ServiceRegistry(); services.AddTransient <IWidget>(x => new AWidget()); // Can't tell that it's an AWidget, so add scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeTrue(); services = new ServiceRegistry(); services.AddTransient <IWidget, AWidget>(); scanner.ShouldAdd(services, typeof(IWidget), typeof(AWidget)).ShouldBeFalse(); }