示例#1
0
        public async Task TestWildcardArgs()
        {
            string testName            = nameof(TestWildcardArgs);
            string entityName          = "ThreeMusketeers";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

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

            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address"]
            // Expand 1...3, renameFormat = {m}{o}
            // Add traits with wildcard characters
            Assert.AreEqual(9, resolvedEntity.Attributes.Count);
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition, "name1", 1, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition, "age1", 1, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition, "address1", 1, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition, "name2", 2, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition, "age2", 2, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition, "address2", 2, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition, "name3", 3, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition, "age3", 3, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition, "address3", 3, "ThreePeople", "address");
        }
示例#2
0
        public async Task TestEntityAttribute()
        {
            string testName            = "TestEntityAttribute";
            string entityName          = "ThreeMusketeers";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

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

            CdmEntityDefinition nonStructuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address"]
            // in non-structured form
            // Expand 1...3;
            // renameFormat = {m}{o};
            // alterTraits = { has.expansionInfo.list(expansionName: "{a}", ordinal: "{o}", memberAttribute: "{mo}") , "argumentsContainWildcards" : true }
            // addArtifactAttribute : "personCount"
            // alterTraits = { indicates.expansionInfo.count(expansionName: "{a}") , apply to "personCount" , "argumentsContainWildcards" : true }
            Assert.AreEqual(10, nonStructuredResolvedEntity.Attributes.Count);
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[0] as CdmTypeAttributeDefinition, "name1", 1, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[1] as CdmTypeAttributeDefinition, "age1", 1, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[2] as CdmTypeAttributeDefinition, "address1", 1, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[3] as CdmTypeAttributeDefinition, "name2", 2, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[4] as CdmTypeAttributeDefinition, "age2", 2, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[5] as CdmTypeAttributeDefinition, "address2", 2, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[6] as CdmTypeAttributeDefinition, "name3", 3, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[7] as CdmTypeAttributeDefinition, "age3", 3, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[8] as CdmTypeAttributeDefinition, "address3", 3, "ThreePeople", "address");
            Assert.AreEqual("personCount", (nonStructuredResolvedEntity.Attributes[9] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("indicates.expansionInfo.count", nonStructuredResolvedEntity.Attributes[9].AppliedTraits[1].NamedReference);
            Assert.AreEqual("ThreePeople", (nonStructuredResolvedEntity.Attributes[9].AppliedTraits[1] as CdmTraitReference).Arguments[0].Value);

            // Original set of attributes: ["name", "age", "address"]
            // in structured form
            // alterTraits = { is.dataFormat.list }
            // addAttributeGroup: favoriteMusketeers
            CdmEntityDefinition structuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
                "structured"
            });

            Assert.AreEqual(1, structuredResolvedEntity.Attributes.Count);
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(structuredResolvedEntity.Attributes, "favoriteMusketeers");

            Assert.IsNotNull(attGroupDefinition.ExhibitsTraits.Item("is.dataFormat.list"));
        }