public void DesignTimeSortTest() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.DesignTime, DependencyInjectionContainer.CompareExportStrategies); collection.AddExport(new FauxExportStrategy(() => ExportEnvironment.RunTime) { Environment = ExportEnvironment.RunTime }, null); collection.AddExport(new FauxExportStrategy(() => ExportEnvironment.DesignTime) { Environment = ExportEnvironment.DesignTime }, null); collection.AddExport(new FauxExportStrategy(() => ExportEnvironment.UnitTest) { Environment = ExportEnvironment.UnitTest }, null); Assert.Equal(ExportEnvironment.DesignTime, collection.Activate(null, null, new FauxInjectionContext(), null, null)); Assert.Equal(3, collection.ActivateAll<ExportEnvironment>(new FauxInjectionContext(), null, null).Count()); }
public void ActivateAll() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.RunTime, DependencyInjectionContainer.CompareExportStrategies); collection.AddExport(new FauxExportStrategy(() => 5) { Priority = 5 }, null); collection.AddExport(new FauxExportStrategy(() => 10) { Priority = 10 }, null); collection.AddExport(new FauxExportStrategy(() => 1) { Priority = 1 }, null); List<int> exports = new List<int>(collection.ActivateAll<int>(new FauxInjectionContext(), null, null)); Assert.Equal(3, exports.Count); Assert.Equal(10, exports[0]); Assert.Equal(5, exports[1]); Assert.Equal(1, exports[2]); }
public void ActivateTest() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.RunTime, DependencyInjectionContainer.CompareExportStrategies); collection.AddExport(new FauxExportStrategy(() => 5), null); Assert.Equal(5, collection.Activate(null, null, new FauxInjectionContext(), null, null)); }
public void DisposeTwiceTest() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.RunTime, DependencyInjectionContainer.CompareExportStrategies); collection.AddExport(new FauxExportStrategy(() => 5), null); collection.Dispose(); collection.Dispose(); }
public void RemoveTest() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.RunTime, DependencyInjectionContainer.CompareExportStrategies); FauxExportStrategy tenExport = new FauxExportStrategy(() => 10) { Priority = 10 }; collection.AddExport(new FauxExportStrategy(() => 5) { Priority = 5 }, null); collection.AddExport(tenExport, null); collection.AddExport(new FauxExportStrategy(() => 1) { Priority = 1 }, null); Assert.Equal(10, collection.Activate(null, null, new FauxInjectionContext(), null, null)); collection.RemoveExport(tenExport, null); Assert.Equal(5, collection.Activate(null, null, new FauxInjectionContext(), null, null)); Assert.Equal(2, collection.ActivateAll<int>(new FauxInjectionContext(), null, null).Count()); }