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 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 EmptyActivate() { ExportStrategyCollection collection = new ExportStrategyCollection(new FauxInjectionScope(), ExportEnvironment.RunTime, DependencyInjectionContainer.CompareExportStrategies); object activated = collection.Activate(null, null, new FauxInjectionContext(), null, null); Assert.Null(activated); }
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()); }