public void GetSourceDataCookersForTablesTest1() { var requiredDataCookers = new List <DataCookerPath> { Source1Cooker1Path, }; var table1 = new TestTableExtensionReference { TableDescriptor = new TableDescriptor( Guid.Parse("{ADE569AF-4460-4DCC-A7C8-9748737AE592}"), "Table1", "Table1 Description", "General", false, TableLayoutStyle.GraphAndTable, requiredDataCookers), BuildTableAction = (tableBuilder, dataRetrieval) => { }, }; var testRepo = new TestDataExtensionRepository(); testRepo.tablesById.Add(table1.TableDescriptor.Guid, table1); AddRequiredDataExtensions(table1, testRepo); var tableSelector = new TableExtensionSelector(testRepo); Assert.AreEqual(tableSelector.Tables.Count, 1); var requiredSourceDataCookers = tableSelector.GetSourceDataCookersForTables(new [] { table1.TableDescriptor.Guid }); Assert.AreEqual(requiredSourceDataCookers.Count, 1); var sourceId = requiredDataCookers[0].SourceParserId; Assert.IsTrue(requiredSourceDataCookers.ContainsKey(sourceId)); Assert.AreEqual(requiredSourceDataCookers[sourceId].Count(), 1); }
/// <summary> /// This enables all required source data cookers for each specified table. Doing so will ensure that the /// table has the required data to build. /// </summary> /// <param name="self"> /// The data extension repository. /// </param> /// <param name="processors"> /// The source processors that are available to generate data. /// </param> /// <param name="enabledTables"> /// Table references that the caller is interested in building. /// </param> /// <returns> /// The set of custom data processors that have data cookers enabled in order to build the requested set /// of tables. /// </returns> public static ISet <ICustomDataProcessorWithSourceParser> EnableSourceDataCookersForTables( this IDataExtensionRepository self, IEnumerable <ICustomDataProcessorWithSourceParser> processors, HashSet <ITableExtensionReference> enabledTables) { Guard.NotNull(self, nameof(self)); Guard.NotNull(processors, nameof(processors)); Guard.NotNull(enabledTables, nameof(enabledTables)); var customProcessors = new HashSet <ICustomDataProcessorWithSourceParser>(); var availableTableExtensions = new TableExtensionSelector(self); var requiredReferencesBySourceId = availableTableExtensions.GetSourceDataCookersForTables(enabledTables); foreach (var processor in processors) { if (requiredReferencesBySourceId.TryGetValue( processor.SourceParserId, out var requiredCookerReferences)) { if (!requiredCookerReferences.Any()) { continue; } customProcessors.Add(processor); foreach (var cookerReference in requiredCookerReferences) { processor.EnableCooker(cookerReference); } } } return(customProcessors); }