Ejemplo n.º 1
0
        private async Task LoadEntityForResolutionOptionAndSave(string testName, string entityName, List <string> resOpts)
        {
            CdmCorpusDefinition   corpus   = TestHelper.GetLocalCorpus(testsSubpath, testName);
            CdmManifestDefinition manifest = await corpus.FetchObjectAsync <CdmManifestDefinition>($"local:/default.manifest.cdm.json");

            string expectedOutputPath = TestHelper.GetExpectedOutputFolderPath(testsSubpath, testName);
            string fileNameSuffix     = ProjectionTestUtils.GetResolutionOptionNameSuffix(resOpts);

            CdmEntityDefinition entSalesForeignKeyProjection = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}", manifest);

            Assert.IsNotNull(entSalesForeignKeyProjection);
            CdmEntityDefinition resolvedSalesForeignKeyProjection = await SaveResolved(corpus, manifest, testName, entSalesForeignKeyProjection, resOpts);

            Assert.IsNotNull(resolvedSalesForeignKeyProjection);
            await AttributeContextUtil.ValidateAttributeContext(corpus, expectedOutputPath, $"{entityName}{fileNameSuffix}", resolvedSalesForeignKeyProjection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads an entity, resolves it, and then validates the generated attribute contexts
        /// </summary>
        private async Task LoadEntityForResolutionOptionAndSave(string testName, string entityName, List <string> resOpts)
        {
            string expectedOutputPath = TestHelper.GetExpectedOutputFolderPath(testsSubpath, testName);
            string fileNameSuffix     = ProjectionTestUtils.GetResolutionOptionNameSuffix(resOpts);

            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            corpus.Storage.Mount("expected", new LocalAdapter(expectedOutputPath));

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            Assert.IsNotNull(entity);
            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, resOpts, true);

            Assert.IsNotNull(resolvedEntity);

            await ValidateResolvedAttributes(corpus, resolvedEntity, entityName, fileNameSuffix);

            await AttributeContextUtil.ValidateAttributeContext(corpus, expectedOutputPath, $"{entityName}{fileNameSuffix}", resolvedEntity);
        }
Ejemplo n.º 3
0
        private async Task <CdmEntityDefinition> SaveResolved(CdmCorpusDefinition corpus, CdmManifestDefinition manifest, string testName, CdmEntityDefinition inputEntity, List <string> resolutionOptions)
        {
            HashSet <string> roHashSet = new HashSet <string>();

            for (int i = 0; i < resolutionOptions.Count; i++)
            {
                roHashSet.Add(resolutionOptions[i]);
            }

            string fileNameSuffix = ProjectionTestUtils.GetResolutionOptionNameSuffix(resolutionOptions);

            string resolvedEntityName = $"Resolved_{inputEntity.EntityName}{fileNameSuffix}.cdm.json";

            ResolveOptions ro = new ResolveOptions(inputEntity.InDocument)
            {
                Directives = new AttributeResolutionDirectiveSet(roHashSet)
            };

            CdmFolderDefinition resolvedFolder = corpus.Storage.FetchRootFolder("output");
            CdmEntityDefinition resolvedEntity = await inputEntity.CreateResolvedEntityAsync(resolvedEntityName, ro, resolvedFolder);

            return(resolvedEntity);
        }