public void Requires2B() { IServiceCollection register = MockRegister(); TypeLoader typeLoader = MockTypeLoader(); IServiceProvider factory = MockFactory(); var composition = new UmbracoBuilder(register, Mock.Of <IConfiguration>(), TestHelper.GetMockedTypeLoader()); Type[] types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) }; var composers = new ComposerGraph(composition, types, Enumerable.Empty <Attribute>(), Mock.Of <ILogger <ComposerGraph> >()); Composed.Clear(); composers.Compose(); ComponentCollectionBuilder builder = composition.WithCollectionBuilder <ComponentCollectionBuilder>(); builder.RegisterWith(register); ComponentCollection components = builder.CreateCollection(factory); Assert.AreEqual(3, Composed.Count); Assert.AreEqual(typeof(Composer4), Composed[0]); Assert.AreEqual(typeof(Composer2), Composed[1]); Assert.AreEqual(typeof(Composer9), Composed[2]); }
public void Boot1A() { IServiceCollection register = MockRegister(); var composition = new UmbracoBuilder(register, Mock.Of <IConfiguration>(), TestHelper.GetMockedTypeLoader()); Type[] types = TypeArray <Composer1, Composer2, Composer4>(); var composers = new ComposerGraph(composition, types, Enumerable.Empty <Attribute>(), Mock.Of <ILogger <ComposerGraph> >()); Composed.Clear(); // 2 is Core and requires 4 // 3 is User // => reorder components accordingly composers.Compose(); AssertTypeArray(TypeArray <Composer1, Composer4, Composer2>(), Composed); IServiceProvider factory = MockFactory(m => { m.Setup(x => x.GetService(It.Is <Type>(t => t == typeof(ISomeResource)))).Returns(() => new SomeResource()); m.Setup(x => x.GetService(It.IsAny <Type>())).Returns <Type>((type) => { if (type == typeof(Composer1)) { return(new Composer1()); } if (type == typeof(Composer5)) { return(new Composer5()); } if (type == typeof(Component5)) { return(new Component5(new SomeResource())); } if (type == typeof(IProfilingLogger)) { return(new ProfilingLogger(Mock.Of <ILogger <ProfilingLogger> >(), Mock.Of <IProfiler>())); } if (type == typeof(ILogger <ComponentCollection>)) { return(Mock.Of <ILogger <ComponentCollection> >()); } throw new NotSupportedException(type.FullName); }); }); ComponentCollectionBuilder builder = composition.WithCollectionBuilder <ComponentCollectionBuilder>(); builder.RegisterWith(register); ComponentCollection components = builder.CreateCollection(factory); Assert.IsEmpty(components); components.Initialize(); Assert.IsEmpty(Initialized); components.Terminate(); Assert.IsEmpty(Terminated); }