public void LazyImportMany(IContainer container) { var lazyImport = container.GetExportedValue <ExportWithListOfLazyImport>(); Assert.Equal(1, lazyImport.AnotherExports.Count); Assert.Equal(0, AnotherExport.ConstructionCount); Assert.False(lazyImport.AnotherExports[0].IsValueCreated); AnotherExport anotherExport = lazyImport.AnotherExports[0].Value; Assert.Equal(1, AnotherExport.ConstructionCount); }
public void LazyImport(IContainer container) { var lazyImport = container.GetExportedValue <ExportWithLazyImport>(); Assert.Equal(0, AnotherExport.ConstructionCount); Assert.False(lazyImport.AnotherExport.IsValueCreated); AnotherExport anotherExport = lazyImport.AnotherExport.Value; Assert.Equal(1, AnotherExport.ConstructionCount); // Verify that another instance gets its own instance of what it's importing (since it's non-shared). var lazyImport2 = container.GetExportedValue <ExportWithLazyImport>(); Assert.Equal(1, AnotherExport.ConstructionCount); Assert.False(lazyImport2.AnotherExport.IsValueCreated); AnotherExport anotherExport2 = lazyImport2.AnotherExport.Value; Assert.Equal(2, AnotherExport.ConstructionCount); Assert.NotSame(anotherExport, anotherExport2); }