Пример #1
0
        public void TestSetup()
        {
            // Pass: 0, Block: 0
            this.dataCooker1 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker1"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[] { }
            };

            // Pass: 0, Block: 0
            this.dataCooker4 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker4"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = new ReadOnlyDictionary <DataCookerPath, DataCookerDependencyType>(
                    new Dictionary <DataCookerPath, DataCookerDependencyType>()
                {
                    { this.dataCooker1.Path, DataCookerDependencyType.SamePass },
                }),
                RequiredDataCookers = new[] { this.dataCooker1.Path }
            };

            // Pass: 0, Block: 1
            this.dataCooker3 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker3"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.AsConsumed,
                DependencyTypes        = new ReadOnlyDictionary <DataCookerPath, DataCookerDependencyType>(
                    new Dictionary <DataCookerPath, DataCookerDependencyType>()
                {
                    { this.dataCooker1.Path, DataCookerDependencyType.AsConsumed },
                }),
                RequiredDataCookers = new[] { this.dataCooker1.Path }
            };

            // Pass: 1, Block: 0
            this.dataCooker2 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker2"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.AsConsumed,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new[] { this.dataCooker1.Path }
            };

            // Pass: 1, Block: 1
            this.dataCooker5 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker5"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new[] { this.dataCooker2.Path }
            };

            // Pass: 1, Block: 2
            this.dataCooker6 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker6"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = new ReadOnlyDictionary <DataCookerPath, DataCookerDependencyType>(
                    new Dictionary <DataCookerPath, DataCookerDependencyType>()
                {
                    { this.dataCooker5.Path, DataCookerDependencyType.AsConsumed },
                }),
                RequiredDataCookers = new[] { this.dataCooker5.Path }
            };

            // Pass: 1, Block: 2
            this.dataCooker7 = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "Cooker7"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = new ReadOnlyDictionary <DataCookerPath, DataCookerDependencyType>(
                    new Dictionary <DataCookerPath, DataCookerDependencyType>()
                {
                    { this.dataCooker6.Path, DataCookerDependencyType.SamePass },
                }),
                RequiredDataCookers = new[] { this.dataCooker6.Path }
            };

            this.expectedPass0Cookers.Add(this.dataCooker1);
            this.expectedPass0Cookers.Add(this.dataCooker3);
            this.expectedPass0Cookers.Add(this.dataCooker4);
            this.expectedPass1Cookers.Add(this.dataCooker2);
            this.expectedPass1Cookers.Add(this.dataCooker5);
            this.expectedPass1Cookers.Add(this.dataCooker6);
            this.expectedPass1Cookers.Add(this.dataCooker7);
        }
Пример #2
0
        public void ScheduleDependenciesAfterDependent()
        {
            var dataCookerA = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "CookerA"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[] { }
            };

            var dataCookerB = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "CookerB"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[] { }
            };

            var dataCookerC = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "CookerC"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[] { }
            };

            var dataCookerD = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "CookerD"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.AsConsumed,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[]
                {
                    dataCookerA.Path,
                    dataCookerB.Path,
                    dataCookerC.Path
                }
            };

            var dataCookerE = new ValidSourceDataCookerWithoutDependencies
            {
                Path                   = new DataCookerPath(SourceParserId, "CookerE"),
                Description            = "Test data cooker",
                DataProductionStrategy = DataProductionStrategy.PostSourceParsing,
                DependencyTypes        = EmptyDependencyTypes,
                RequiredDataCookers    = new DataCookerPath[]
                {
                    dataCookerD.Path
                }
            };

            var sourceCookers = new List <ValidSourceDataCookerWithoutDependencies>()
            {
                dataCookerE,
                dataCookerD,
                dataCookerA,
                dataCookerB,
                dataCookerC
            };

            var scheduler = new SourceDataCookerScheduler(SourceParserId);

            scheduler.ScheduleDataCookers(sourceCookers);

            List <List <IDataCookerDescriptor> > cookersByPass = scheduler.DataCookersBySourcePass;

            // Expect that there are 2 passes
            Assert.AreEqual(cookersByPass.Count, 2);

            // Check the sizes of the 2 passes
            // Cookers A, B, C have no dependencies and should be in pass 0.
            // Cookers D & E have dependencies and should be in pass 1.
            Assert.AreEqual(cookersByPass[0].Count, 3);
            Assert.AreEqual(cookersByPass[1].Count, 2);

            // Check the cookers are in their expected passes
            Assert.IsTrue(cookersByPass[0].Contains(dataCookerA));
            Assert.IsTrue(cookersByPass[0].Contains(dataCookerB));
            Assert.IsTrue(cookersByPass[0].Contains(dataCookerC));

            Assert.IsTrue(cookersByPass[1].Contains(dataCookerD));
            Assert.IsTrue(cookersByPass[1].Contains(dataCookerE));

            // Verify that necessary ordering withing a pass is met
            Assert.IsTrue(cookersByPass[1].IndexOf(dataCookerD) < cookersByPass[1].IndexOf(dataCookerE));
        }