public void CannotAppendToBuilderOnceCollectionIsCreated() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>(); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); Assert.Throws <InvalidOperationException>(() => builder.Append <Resolved1>()); }
public void CanInsertIntoEmptyBuilder() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>(); builder.Insert <Resolved2>(); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved2)); }
public void CanInsertDuplicateIntoBuilderBeforeAndDeDuplicate() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>() .Append <Resolved1>() .Append <Resolved2>() .InsertBefore <Resolved1, Resolved2>(); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved2), typeof(Resolved1)); }
public void CanRemoveMissingFromBuilder() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>() .Append <Resolved1>() .Append <Resolved2>() .Remove <Resolved3>(); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved1), typeof(Resolved2)); }
public void CanAppendDuplicateToBuilderAndDeDuplicate() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>(); builder.Append <Resolved1>(); builder.Append <Resolved1>(); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved1)); }
public void CanClearBuilderBeforeCollectionIsCreated() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>() .Append <Resolved1>() .Append <Resolved2>(); builder.Clear(); Assert.IsFalse(builder.Has <Resolved1>()); Assert.IsFalse(builder.Has <Resolved2>()); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col); }
public void CanAppendToBuilder() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>(); builder.Append <Resolved1>(); builder.Append <Resolved2>(); Assert.IsTrue(builder.Has <Resolved1>()); Assert.IsTrue(builder.Has <Resolved2>()); Assert.IsFalse(builder.Has <Resolved3>()); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved1), typeof(Resolved2)); }
public void ContainsTypes() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>() .Append <Resolved1>() .Append <Resolved2>(); Assert.IsTrue(builder.Has <Resolved1>()); Assert.IsTrue(builder.Has <Resolved2>()); Assert.IsFalse(builder.Has <Resolved3>()); //// Assert.IsFalse(col.ContainsType<Resolved4>()); // does not compile IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved1), typeof(Resolved2)); }
public void CanInsertIntoBuilderAfterLast() { TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>() .Append <Resolved1>() .Append <Resolved2>() .InsertAfter <Resolved2, Resolved3>(); Assert.IsTrue(builder.Has <Resolved1>()); Assert.IsTrue(builder.Has <Resolved2>()); Assert.IsTrue(builder.Has <Resolved3>()); IServiceProvider factory = _composition.CreateServiceProvider(); TestCollection col = builder.CreateCollection(factory); AssertCollection(col, typeof(Resolved1), typeof(Resolved2), typeof(Resolved3)); }