Exemplo n.º 1
0
        public void ConstructableNamedTypeDefinitionToStringTest()
        {
            IEdmEntityType    astonishing  = new EdmEntityType("AwesomeNamespace", "AstonishingEntity", null, false, false);
            IEdmEntityType    aweInspiring = new EdmEntityType("AwesomeNamespace", "AweInspiringEntity", null, false, false);
            IEdmComplexType   breathTaking = new EdmComplexType("AwesomeNamespace", "BreathtakingComplex", null, false);
            IEdmPrimitiveType primitive    = (IEdmPrimitiveType)EdmCoreModel.Instance.GetInt32(false).Definition;

            Assert.AreEqual("AwesomeNamespace.AstonishingEntity", astonishing.ToString(), "To string correct");
            Assert.AreEqual("AwesomeNamespace.AweInspiringEntity", aweInspiring.ToString(), "To string correct");
            Assert.AreEqual("AwesomeNamespace.BreathtakingComplex", breathTaking.ToString(), "To string correct");
            Assert.AreEqual("Edm.Int32", primitive.ToString(), "To string correct");
        }
Exemplo n.º 2
0
        public void CsdlNamedTypeDefinitionToStringTest()
        {
            const string csdl =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<Schema Namespace=""AwesomeNamespace"" Alias=""Alias"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
  <EntityType Name=""AstonishingEntity"">
    <Key>
      <PropertyRef Name=""Id"" />
    </Key>
    <Property Name=""Id"" Type=""Int32"" Nullable=""false"" />
  </EntityType>
  <EntityType Name=""AweInspiringEntity"">
    <Key>
      <PropertyRef Name=""Id"" />
    </Key>
    <Property Name=""Id"" Type=""Int32"" Nullable=""false"" />
    <Property Name=""AstonishingID"" Type=""Int32"" />
  </EntityType>
  <ComplexType Name=""BreathtakingComplex"">
    <Property Name=""Par1"" Type=""Int32"" Nullable=""false"" />
    <Property Name=""Par2"" Type=""Int32"" Nullable=""false"" />
  </ComplexType>
  <EnumType Name=""FabulousEnum"">
    <Member Name=""m1"" />
    <Member Name=""m2"" />
  </EnumType>
</Schema>";
            IEdmModel model;
            IEnumerable <EdmError> errors;
            bool parsed = CsdlReader.TryParse(new XmlReader[] { XmlReader.Create(new StringReader(csdl)) }, out model, out errors);

            Assert.IsTrue(parsed, "parsed");
            Assert.IsTrue(errors.Count() == 0, "No errors");

            IEdmEntityType    astonishing  = (IEdmEntityType)model.FindType("AwesomeNamespace.AstonishingEntity");
            IEdmEntityType    aweInspiring = (IEdmEntityType)model.FindType("AwesomeNamespace.AweInspiringEntity");
            IEdmComplexType   breathTaking = (IEdmComplexType)model.FindType("AwesomeNamespace.BreathtakingComplex");
            IEdmPrimitiveType primitive    = (IEdmPrimitiveType)astonishing.FindProperty("Id").Type.Definition;
            IEdmEnumType      fabulous     = (IEdmEnumType)model.FindType("AwesomeNamespace.FabulousEnum");

            Assert.AreEqual("AwesomeNamespace.AstonishingEntity", astonishing.ToString(), "To string correct");
            Assert.AreEqual("AwesomeNamespace.AweInspiringEntity", aweInspiring.ToString(), "To string correct");
            Assert.AreEqual("AwesomeNamespace.BreathtakingComplex", breathTaking.ToString(), "To string correct");
            Assert.AreEqual("Edm.Int32", primitive.ToString(), "To string correct");
            Assert.AreEqual("AwesomeNamespace.FabulousEnum", fabulous.ToString(), "To string correct");
        }