public async Task TestArgumentNull() { var compositionBootstrapper = new CompositionBootstrapper(); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Add((Assembly) null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Add((AssemblyCatalog) null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.FindAndLoadAssembly(null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Add((Type) null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Add((ExportProvider) null)); await compositionBootstrapper.InitializeAsync().ConfigureAwait(false); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Export<string>(null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.Release(null)); Assert.Throws<ArgumentNullException>(() => compositionBootstrapper.FillImports(null)); compositionBootstrapper.Dispose(); }
public void TestNotInitialized() { var compositionBootstrapper = new CompositionBootstrapper(); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.Export("Hello")); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExport<string>()); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExport<string, IStartupActionMetadata>()); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExport(typeof(string))); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetService(typeof(string))); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExports(typeof(string))); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExports<string>()); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.GetExports<string, IStartupActionMetadata>()); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.Release(null)); Assert.Throws<InvalidOperationException>(() => compositionBootstrapper.FillImports(null)); compositionBootstrapper.Dispose(); }