Exemple #1
0
        public void TestZeroMinimumCardinality()
        {
            string testName = "TestZeroMinimumCardinality";

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

            corpus.SetEventCallback(new EventCallback
            {
                Invoke = (CdmStatusLevel statusLevel, string message) =>
                {
                    Assert.Fail(message);
                }
            }, CdmStatusLevel.Warning);

            // Create Local Root Folder
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create Manifest
            CdmManifestDefinition manifest = corpus.MakeObject <CdmManifestDefinition>(CdmObjectType.ManifestDef, "default");

            localRoot.Documents.Add(manifest, "default.manifest.cdm.json");

            string entityName = "TestEntity";

            // Create Entity
            CdmEntityDefinition entity = corpus.MakeObject <CdmEntityDefinition>(CdmObjectType.EntityDef, entityName);

            entity.ExtendsEntity = corpus.MakeRef <CdmEntityReference>(CdmObjectType.EntityRef, "CdmEntity", true);

            // Create Entity Document
            CdmDocumentDefinition document = corpus.MakeObject <CdmDocumentDefinition>(CdmObjectType.DocumentDef, $"{entityName}.cdm.json", false);

            document.Definitions.Add(entity);
            localRoot.Documents.Add(document, document.Name);
            manifest.Entities.Add(entity);

            string attributeName     = "testAttribute";
            string attributeDataType = "string";
            string attributePurpose  = "hasA";

            // Create Type Attribute
            CdmTypeAttributeDefinition attribute = corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, nameOrRef: attributeName, simpleNameRef: false);

            attribute.DataType    = corpus.MakeRef <CdmDataTypeReference>(CdmObjectType.DataTypeRef, refObj: attributeDataType, simpleNameRef: true);
            attribute.Purpose     = corpus.MakeRef <CdmPurposeReference>(CdmObjectType.PurposeRef, refObj: attributePurpose, simpleNameRef: true);
            attribute.DisplayName = attributeName;

            if (entity != null)
            {
                entity.Attributes.Add(attribute);
            }

            attribute.Cardinality = new CardinalitySettings(attribute)
            {
                Minimum = "0",
                Maximum = "*"
            };

            Assert.IsTrue(attribute.IsNullable == true);
        }
        public async Task TestGroupProj()
        {
            string testName            = "TestGroupProj";
            string entityName          = "ThreeMusketeers";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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}
            Assert.AreEqual(9, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name1", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name2", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age2", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address2", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name3", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age3", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address3", (resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition).Name);
        }
Exemple #3
0
        public async Task TestExtendsEntity()
        {
            string testName            = "TestExtendsEntity";
            string entityName          = "Customer";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
            // Type attribute: "someType" (using extendsEntityResolutionGuidance)
            Assert.AreEqual(8, resolvedEntity.Attributes.Count);
            Assert.AreEqual("emailId", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("isPrimary", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneId", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("number", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("socialId", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("account", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("someType", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("is.linkedEntity.name", resolvedEntity.Attributes[7].AppliedTraits[4].NamedReference);
        }
Exemple #4
0
        public async Task TestInvalidOperationType()
        {
            string testName = "TestInvalidOperationType";

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

            corpus.SetEventCallback(new EventCallback
            {
                Invoke = (CdmStatusLevel statusLevel, string message) =>
                {
                    if (!message.Contains("ProjectionPersistence | Invalid operation type 'replaceAsForeignKey11111'. | FromData"))
                    {
                        Assert.Fail(message);
                    }
                }
            }, CdmStatusLevel.Warning);

            CdmManifestDefinition manifest = await corpus.FetchObjectAsync <CdmManifestDefinition>($"default.manifest.cdm.json");

            // Raise error: $"ProjectionPersistence | Invalid operation type 'replaceAsForeignKey11111'. | FromData",
            // when attempting to load a projection with an invalid operation
            string entityName          = "SalesNestedFK";
            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}", manifest);

            Assert.IsNotNull(entity);
        }
Exemple #5
0
        public async Task TestCombineOpsNestedProj()
        {
            string testName            = "TestCombineOpsNestedProj";
            string entityName          = "Customer";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
            // Merge ["emailId, "phoneId, "socialId"] into "contactId", type attribute: "contactType",
            // rename ["contactId", "isPrimary"] as "new_{m}", include ["contactId", "new_isPrimary", "contactType"]
            Assert.AreEqual(3, resolvedEntity.Attributes.Count);
            Assert.AreEqual("new_isPrimary", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("new_contactId", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("contactType", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("is.linkedEntity.name", resolvedEntity.Attributes[2].AppliedTraits[4].NamedReference);
        }
Exemple #6
0
        public async Task TestConditionalProj()
        {
            string testName            = "TestConditionalProj";
            string entityName          = "Customer";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
            // Merge ["emailId, "phoneId, "socialId"] into "contactId", type attribute: "contactType"
            // Condition for projection containing AddTypeAttribute is false, so no Type attribute is created
            Assert.AreEqual(5, resolvedEntity.Attributes.Count);
            Assert.AreEqual("address", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("isPrimary", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("number", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("account", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("contactId", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestEANameProj()
        {
            string testName            = "TestEANameProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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> {
                "structured"
            });

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email", "title", "company", "tenure"]
            // Excluded attributes: ["OccupationInfo"] (name of entity attribute that contains "title", "company", "tenure")
            Assert.AreEqual(1, resolvedEntity.Attributes.Count); // attribute group created because of structured directive
            CdmAttributeGroupDefinition attGroup = (resolvedEntity.Attributes[0] as CdmAttributeGroupReference).ExplicitReference as CdmAttributeGroupDefinition;

            Assert.AreEqual(5, attGroup.Members.Count);
            Assert.AreEqual("name", (attGroup.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (attGroup.Members[1] as CdmTypeAttributeDefinition).Name, "age");
            Assert.AreEqual("address", (attGroup.Members[2] as CdmTypeAttributeDefinition).Name, "address");
            Assert.AreEqual("phoneNumber", (attGroup.Members[3] as CdmTypeAttributeDefinition).Name, "phoneNumber");
            Assert.AreEqual("email", (attGroup.Members[4] as CdmTypeAttributeDefinition).Name, "email");
        }
Exemple #8
0
        public async Task TestTypeAttributeProj()
        {
            string testName            = "TestTypeAttributeProj";
            string entityName          = "Person";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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> {
                "referenceOnly"
            });

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // Add attribute group applied to "address"
            Assert.AreEqual(5, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            CdmAttributeGroupDefinition attGroupDefinition = this.ValidateAttributeGroup(resolvedEntity.Attributes, "AddressAttributeGroup", 5, 2);

            Assert.AreEqual("address", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
        }
Exemple #9
0
        public async Task TestCombineOpsProj()
        {
            string testName            = "TestCombineOpsProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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", "phoneNumber", "email"]
            // Included attributes: ["age", "phoneNumber"]
            CdmAttributeGroupDefinition attGroupDefinition = this.ValidateAttributeGroup(resolvedEntity.Attributes, "PersonAttributeGroup", 3);

            Assert.AreEqual(5, attGroupDefinition.Members.Count);
            Assert.AreEqual("name", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (attGroupDefinition.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (attGroupDefinition.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (attGroupDefinition.Members[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (attGroupDefinition.Members[4] as CdmTypeAttributeDefinition).Name);

            // Check the attributes coming from the IncludeAttribute operation
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestPolymorphic()
        {
            string testName            = "TestPolymorphic";
            string entityName          = "BusinessPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["emailId", "address", "isPrimary", "phoneId", "number"]
            // Expand 1...2, renameFormat = {m}{o}
            Assert.AreEqual(11, resolvedEntity.Attributes.Count);
            Assert.AreEqual("count", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("emailId1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("isPrimary1", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneId1", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("number1", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("emailId2", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address2", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("isPrimary2", (resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneId2", (resolvedEntity.Attributes[9] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("number2", (resolvedEntity.Attributes[10] as CdmTypeAttributeDefinition).Name);
        }
Exemple #11
0
        public async Task TestWithArrayExpansion()
        {
            string testName            = "TestWithArrayExpansion";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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", "phoneNumber", "email"]
            // Expand 1...2, count attribute: "personCount" (first projection)
            // The first projection will give us the expanded attributes as well as the pass-through input attributes
            // Then do renameFormat = {m}{o} in the second projection
            Assert.AreEqual(11, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name1", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber1", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email1", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name2", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age2", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address2", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber2", (resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email2", (resolvedEntity.Attributes[9] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("personCount", (resolvedEntity.Attributes[10] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("is.linkedEntity.array.count", resolvedEntity.Attributes[10].AppliedTraits[1].NamedReference);
        }
        public async Task TestCombineOpsProj()
        {
            string testName            = "TestCombineOpsProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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", "phoneNumber", "email"]
            // Supporting attribute: "PersonInfo_display", rename "address" to "homeAddress"
            Assert.AreEqual(7, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("homeAddress", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("PersonInfo_display", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            ValidateInSupportOfAttribute(resolvedEntity.Attributes[6], "email");
        }
        public async Task TestArraySource()
        {
            string testName            = "TestArraySource";
            string entityName          = "FriendGroup";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["personCount", "name1", "age1", "address1", "name2", "age2", "address2"]
            // Expand 1...2, renameFormat = {m}_{o}
            // Since resolution guidance doesn't support doing an expansion on an array source, we end up with the
            // following result where it skips expanding attributes with the same ordinal (ex. name1_1, name2_2)
            Assert.AreEqual(9, resolvedEntity.Attributes.Count);
            Assert.AreEqual("count_", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("personCount_1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name2_1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age2_1", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address2_1", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("personCount_2", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name1_2", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age1_2", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address1_2", (resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition).Name);
        }
Exemple #14
0
        public async Task TestArraySourceRename()
        {
            string testName            = "TestArraySourceRename";
            string entityName          = "FriendGroup";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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: ["personCount", "name1", "age1", "address1", "phoneNumber1", "email1", ..., "email3"] (16 total)
            // Excluded attributes: ["age1", "age2", "age3"]
            Assert.AreEqual(13, resolvedEntity.Attributes.Count);
            Assert.AreEqual("personCount", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber1", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email1", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name2", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address2", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber2", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email2", (resolvedEntity.Attributes[8] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name3", (resolvedEntity.Attributes[9] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address3", (resolvedEntity.Attributes[10] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber3", (resolvedEntity.Attributes[11] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email3", (resolvedEntity.Attributes[12] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestTypeAttributeProj()
        {
            string testName            = "TestTypeAttributeProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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> {
                "referenceOnly"
            });

            // Original set of attributes: ["PersonInfo"]
            Assert.AreEqual(2, resolvedEntity.Attributes.Count);
            Assert.AreEqual("PersonInfo", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            CdmTypeAttributeDefinition supportingAttribute = resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition;

            Assert.AreEqual("PersonInfo_display", supportingAttribute.Name);
            ValidateInSupportOfAttribute(supportingAttribute, "PersonInfo");
        }
Exemple #16
0
        public void TestMaximum()
        {
            string testName = "TestMaximum";

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

            corpus.SetEventCallback(new EventCallback
            {
                Invoke = (CdmStatusLevel statusLevel, string message) =>
                {
                    if (!message.Contains("CardinalitySettings | Invalid maximum cardinality Abc."))
                    {
                        Assert.Fail($"Some unexpected failure - {message}!");
                    }
                }
            }, CdmStatusLevel.Warning);

            // Create Dummy Type Attribute
            CdmTypeAttributeDefinition attribute = corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, nameOrRef: "dummyAttribute", simpleNameRef: false);

            attribute.Cardinality = new CardinalitySettings(attribute)
            {
                Maximum = "Abc"
            };
        }
Exemple #17
0
        public async Task TestDuplicate()
        {
            string testName            = "TestDuplicate";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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", "phoneNumber", "email"]
            // Count attribute: "someCount", count attribute: "someCount"
            // "someCount" should get merged into one
            Assert.AreEqual(6, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("someCount", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("is.linkedEntity.array.count", resolvedEntity.Attributes[5].AppliedTraits[1].NamedReference);
        }
Exemple #18
0
        public async Task TestConditionalProj()
        {
            string testName            = "TestConditionalProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.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", "phoneNumber", "email"]
            // Count attribute: "someCount"
            // Condition is false, so no Count attribute added
            Assert.AreEqual(5, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestEntityProjUsingObjectModel()
        {
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, "TestEntityProjUsingObjectModel");

            corpus.Storage.Mount("local", new LocalAdapter(TestHelper.GetActualOutputFolderPath(testsSubpath, "TestEntityProjUsingObjectModel")));
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create an entity
            CdmEntityDefinition entity = ProjectionTestUtils.CreateEntity(corpus, localRoot);

            // Create a projection
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            // Create an ArrayExpansion operation
            CdmOperationArrayExpansion arrayExpansionOp = corpus.MakeObject <CdmOperationArrayExpansion>(CdmObjectType.OperationArrayExpansionDef);

            arrayExpansionOp.StartOrdinal = 1;
            arrayExpansionOp.EndOrdinal   = 2;
            projection.Operations.Add(arrayExpansionOp);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef.ExplicitReference = projection;

            // Create another projection that does a rename so that we can see the expanded attributes in the final resolved entity
            CdmProjection projection2 = corpus.MakeObject <CdmProjection>(CdmObjectType.ProjectionDef);

            projection2.Source = projectionEntityRef;

            // Create a RenameAttributes operation
            CdmOperationRenameAttributes renameAttrsOp = corpus.MakeObject <CdmOperationRenameAttributes>(CdmObjectType.OperationRenameAttributesDef);

            renameAttrsOp.RenameFormat = "{m}{o}";
            projection2.Operations.Add(renameAttrsOp);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef2 = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef2.ExplicitReference = projection2;

            // Set the entity's ExtendEntity to be the projection
            entity.ExtendsEntity = projectionEntityRef2;

            // Resolve the entity
            CdmEntityDefinition resolvedEntity = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", null, localRoot);

            // Verify correctness of the resolved attributes after running the projections
            // Original set of attributes: ["id", "name", "value", "date"]
            // Expand 1...2, renameFormat = {m}{o}
            Assert.AreEqual(8, resolvedEntity.Attributes.Count);
            Assert.AreEqual("id1", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name1", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value1", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date1", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("id2", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name2", (resolvedEntity.Attributes[5] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value2", (resolvedEntity.Attributes[6] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date2", (resolvedEntity.Attributes[7] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestEntityNestedProjection()
        {
            string testName            = "TestEntityNestedProjection";
            string entityName          = testName;
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, new List <string> {
            });
        }
        public async Task TestEntityAttributeStringReference()
        {
            string testName            = "TestEntityAttributeStringReference";
            string entityName          = "TestEntAttrStrRef";
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, new List <string> {
            });
        }
Exemple #22
0
        public async Task TestNestedProjUsingObjectModel()
        {
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, "TestNestedProjUsingObjectModel");

            corpus.Storage.Mount("local", new LocalAdapter(TestHelper.GetActualOutputFolderPath(testsSubpath, "TestNestedProjUsingObjectModel")));
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create an entity
            CdmEntityDefinition entity = ProjectionTestUtils.CreateEntity(corpus, localRoot);

            // Create a projection
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            // Create an ExcludeAttributes operation
            CdmOperationExcludeAttributes excludeAttrsOp = corpus.MakeObject <CdmOperationExcludeAttributes>(CdmObjectType.OperationExcludeAttributesDef);

            excludeAttrsOp.ExcludeAttributes.Add("id");
            excludeAttrsOp.ExcludeAttributes.Add("date");
            projection.Operations.Add(excludeAttrsOp);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef.ExplicitReference = projection;

            // Create another projection that uses the previous projection as its source
            CdmProjection projection2 = corpus.MakeObject <CdmProjection>(CdmObjectType.ProjectionDef);

            projection2.Source = projectionEntityRef;

            // Create an ExcludeAttributes operation
            CdmOperationExcludeAttributes excludeAttrsOp2 = corpus.MakeObject <CdmOperationExcludeAttributes>(CdmObjectType.OperationExcludeAttributesDef);

            excludeAttrsOp2.ExcludeAttributes.Add("value");
            projection2.Operations.Add(excludeAttrsOp2);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef2 = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef2.ExplicitReference = projection2;

            // Create an entity attribute that contains this projection and add this to the entity
            CdmEntityAttributeDefinition entityAttribute = corpus.MakeObject <CdmEntityAttributeDefinition>(CdmObjectType.EntityAttributeDef, "TestEntityAttribute");

            entityAttribute.Entity = projectionEntityRef2;
            entity.Attributes.Add(entityAttribute);

            // Resolve the entity
            CdmEntityDefinition resolvedEntity = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", null, localRoot);

            // Verify correctness of the resolved attributes after running the ExcludeAttributes operations
            // Original set of attributes: ["id", "name", "value", "date"]
            // Excluded attributes: ["id", "date"], ["value"]
            Assert.AreEqual(1, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
        }
Exemple #23
0
        public async Task TestEA()
        {
            string testName            = "TestEA";
            string entityName          = "Color";
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }
        }
        public void TestBuildTree()
        {
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, "TestBuildTree");

            ProjectionContext pc = BuildFakeTree(corpus);

            Assert.AreEqual("1 ==>> [ 12 14 17 .. 1 ..  1]", SearchTreeTraversal(pc, "1"));
            Assert.AreEqual("8 ==>> [ 12 17 .. 8 ..  1]", SearchTreeTraversal(pc, "8"));
            Assert.AreEqual("13 ==>> [ 13 .. 13 ..  4 5 6]", SearchTreeTraversal(pc, "13"));
            Assert.AreEqual("9 ==>> [ 13 .. 9 ..  4 5]", SearchTreeTraversal(pc, "9"));
            Assert.AreEqual("5 ==>> [ 13 .. 5 ..  5]", SearchTreeTraversal(pc, "5"));
            Assert.AreEqual("7 ==>> [ 11 15 .. 7 ..  1]", SearchTreeTraversal(pc, "7"));
        }
Exemple #25
0
        public async Task TestCircularEntityAttributes()
        {
            string testName   = "TestCircularEntityAttributes";
            string entityName = "A";

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

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

            CdmEntityDefinition resEntity = await entity.CreateResolvedEntityAsync($"resolved-{entityName}");

            Assert.IsNotNull(resEntity);
            Assert.AreEqual(2, resEntity.Attributes.Count);
        }
Exemple #26
0
        public async Task TestRenProj()
        {
            string testName            = "TestRenProj";
            string entityName          = "Customer";
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                if (resOpt.Contains("structured"))
                {
                    // Rename attributes is not supported on an attribute group yet.
                    continue;
                }

                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }
        }
Exemple #27
0
        public async Task TestEntityAttributeProjUsingObjectModel()
        {
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, "TestEntityAttributeProjUsingObjectModel");

            corpus.Storage.Mount("local", new LocalAdapter(TestHelper.GetActualOutputFolderPath(testsSubpath, "TestEntityAttributeProjUsingObjectModel")));
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create an entity
            CdmEntityDefinition entity = ProjectionTestUtils.CreateEntity(corpus, localRoot);

            // Create a projection
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            // Create an AddTypeAttribute operation
            CdmOperationAddTypeAttribute addTypeAttrOp = corpus.MakeObject <CdmOperationAddTypeAttribute>(CdmObjectType.OperationAddTypeAttributeDef);

            addTypeAttrOp.TypeAttribute          = corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, "testType");
            addTypeAttrOp.TypeAttribute.DataType = corpus.MakeRef <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "entityName", true);
            projection.Operations.Add(addTypeAttrOp);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef.ExplicitReference = projection;

            // Create an entity attribute that contains this projection and add this to the entity
            CdmEntityAttributeDefinition entityAttribute = corpus.MakeObject <CdmEntityAttributeDefinition>(CdmObjectType.EntityAttributeDef, "TestEntityAttribute");

            entityAttribute.Entity = projectionEntityRef;
            entity.Attributes.Add(entityAttribute);

            // Resolve the entity
            CdmEntityDefinition resolvedEntity = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", null, localRoot);

            // Verify correctness of the resolved attributes after running the AddTypeAttribute operation
            // Original set of attributes: ["id", "name", "value", "date"]
            // Type attribute: "testType"
            Assert.AreEqual(5, resolvedEntity.Attributes.Count);
            Assert.AreEqual("id", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("testType", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("is.linkedEntity.name", resolvedEntity.Attributes[4].AppliedTraits[4].NamedReference);
        }
        public async Task TestProjectionExtendsTrait()
        {
            string testName            = "TestProjectionExtendsTrait";
            string entityName          = testName;
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, new List <string> {
            });

            // Attribute Name
            Assert.AreEqual("TestProjectionAttribute", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[0]).Name);
            // Trait Name
            Assert.AreEqual("does.haveDefault", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[0]).AppliedTraits[3].NamedReference);

            // Trait Name
            Assert.AreEqual("testTrait", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[0]).AppliedTraits[4].NamedReference);
            // Trait Param Name
            Assert.AreEqual("testTraitParam1", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[0]).AppliedTraits[4]).Arguments[0].ResolvedParameter.Name);
            // Trait Param Default Value
            Assert.AreEqual("TestTrait Param 1 DefaultValue", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[0]).AppliedTraits[4]).Arguments[0].Value);


            // Attribute Name
            Assert.AreEqual("TestProjectionAttributeB", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).Name);
            // Trait Name
            Assert.AreEqual("does.haveDefault", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[3].NamedReference);

            // Trait Name
            Assert.AreEqual("testTrait", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[4].NamedReference);
            // Trait Param Name
            Assert.AreEqual("testTraitParam1", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[4]).Arguments[0].ResolvedParameter.Name);
            // Trait Param Default Value
            Assert.AreEqual("TestTrait Param 1 DefaultValue", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[4]).Arguments[0].Value);

            // Trait Name
            Assert.AreEqual("testExtendsTraitB", ((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[5].NamedReference);
            // Trait Param Name
            Assert.AreEqual("testTraitParam1", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[5]).Arguments[0].ResolvedParameter.Name);
            // Trait Param Default Value
            Assert.AreEqual("TestTrait Param 1 DefaultValue", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[5]).Arguments[0].Value);
            // Trait Param Name
            Assert.AreEqual("testExtendsTraitBParam1", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[5]).Arguments[1].ResolvedParameter.Name);
            // Trait Param Default Value
            Assert.AreEqual("TestExtendsTraitB Param 1 DefaultValue", ((CdmTraitReference)((CdmTypeAttributeDefinition)resolvedEntity.Attributes[1]).AppliedTraits[5]).Arguments[1].Value);
        }
Exemple #29
0
        public async Task TestMaxDepthOnPolymorphicEntity()
        {
            string testName   = "TestMaxDepthOnPolymorphicEntity";
            string entityName = "A";

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

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

            ResolveOptions resOpt = new ResolveOptions(entity)
            {
                MaxDepth = 1
            };
            CdmEntityDefinition resEntity = await entity.CreateResolvedEntityAsync($"resolved-{entityName}", resOpt);

            Assert.IsNotNull(resEntity);
            Assert.AreEqual(4, resEntity.Attributes.Count);
        }
Exemple #30
0
        public async Task TestRunSequentiallyAndSourceInput()
        {
            string testName            = "TestRunSequentiallyAndSourceInput";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = ProjectionTestUtils.GetLocalCorpus(testsSubpath, testName);

            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", "phoneNumber", "email"]
            // Replace "age" with "ageFK" and "address" with "addressFK" as foreign keys, followed by a add count attribute.
            Assert.AreEqual(3, resolvedEntity.Attributes.Count);
            Assert.AreEqual("ageFK", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("addressFK", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("countAttribute", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
        }