Example #1
0
 public static void ValidateTypeAttributeDefinition(AttributeExpectedValue expected, CdmTypeAttributeDefinition actual)
 {
     Assert.AreEqual(expected.DataFormat, actual.DataFormat.ToString());
     Assert.AreEqual(expected.DataType, actual.DataType);
     Assert.AreEqual(expected.Description, actual.Description);
     Assert.AreEqual(expected.DisplayName, actual.DisplayName);
     Assert.AreEqual(expected.Explanation, actual.Explanation);
     Assert.AreEqual(expected.IsNullable, actual.IsNullable);
     Assert.AreEqual(expected.IsPrimaryKey, actual.IsPrimaryKey);
     Assert.AreEqual(expected.IsReadOnly, actual.IsReadOnly);
     Assert.AreEqual(expected.MaximumLength, actual.MaximumLength);
     Assert.AreEqual(expected.MaximumValue, actual.MaximumValue);
     Assert.AreEqual(expected.MinimumValue, actual.MinimumValue);
     Assert.AreEqual(expected.Name, actual.Name);
     Assert.AreEqual(expected.Purpose, actual.Purpose);
     Assert.AreEqual(expected.SourceName, actual.SourceName);
     Assert.AreEqual(expected.SourceOrdering, actual.SourceOrdering);
 }
Example #2
0
 public static void ValidateAttributesCollection(List <AttributeExpectedValue> expected, CdmCollection <CdmAttributeItem> actual)
 {
     Assert.AreEqual(expected.Count, actual.Count);
     for (int i = 0; i < actual.AllItems.Count; i++)
     {
         if (actual.AllItems[i].GetType() == typeof(CdmTypeAttributeDefinition))
         {
             AttributeExpectedValue     exp = (AttributeExpectedValue)expected[i];
             CdmTypeAttributeDefinition act = (CdmTypeAttributeDefinition)actual.AllItems[i];
             ValidateTypeAttributeDefinition(exp, act);
         }
         else if (actual.AllItems[i].GetType() == typeof(CdmAttributeGroupReference))
         {
             AttributeExpectedValue     exp = (AttributeExpectedValue)expected[i];
             CdmAttributeGroupReference act = (CdmAttributeGroupReference)actual.AllItems[i];
             ValidateAttributeGroupRef(exp, act);
         }
     }
 }
Example #3
0
        public static void ValidateAttributeGroupRef(AttributeExpectedValue expected, CdmAttributeGroupReference actual)
        {
            if (expected.AttributeGroupName != null || expected.Members != null)
            {
                if (actual.ExplicitReference != null)
                {
                    CdmAttributeGroupDefinition actualObj = ((CdmAttributeGroupDefinition)actual.ExplicitReference);

                    if (expected.AttributeGroupName != null)
                    {
                        Assert.AreEqual(expected.AttributeGroupName, actualObj.AttributeGroupName);
                    }
                    if (expected.AttributeContext != null)
                    {
                        Assert.AreEqual(expected.AttributeContext, actualObj.AttributeContext.NamedReference);
                    }
                    if (expected.Members != null)
                    {
                        Assert.AreEqual(expected.Members.Count, actualObj.Members.Count);
                        for (int i = 0; i < actualObj.Members.Count; i++)
                        {
                            if (actualObj.Members[i].GetType() == typeof(CdmTypeAttributeDefinition))
                            {
                                AttributeExpectedValue     exp = (AttributeExpectedValue)expected.Members[i];
                                CdmTypeAttributeDefinition act = (CdmTypeAttributeDefinition)actualObj.Members[i];
                                ValidateTypeAttributeDefinition(exp, act);
                            }
                            else if (actualObj.Members[i].GetType() == typeof(CdmAttributeGroupReference))
                            {
                                AttributeExpectedValue     exp = (AttributeExpectedValue)expected.Members[i];
                                CdmAttributeGroupReference act = (CdmAttributeGroupReference)actualObj.Members[i];
                                ValidateAttributeGroupRef(exp, act);
                            }
                            else
                            {
                                throw new NotImplementedException("Unknown type!");
                            }
                        }
                    }
                }
            }
        }