Example #1
0
        public void EdmItemCollection_Create_factory_method_throws_for_null_reader_in_the_collection()
        {
            IList <EdmSchemaError> errors;

            Assert.Equal(Strings.CheckArgumentContainsNullFailed("xmlReaders"),
                         Assert.Throws <ArgumentException>(
                             () => EdmItemCollection.Create(new XmlReader[1], null, out errors)).Message);
        }
Example #2
0
        public void EdmItemCollection_Create_factory_method_throws_for_null_readers()
        {
            IList <EdmSchemaError> errors;

            Assert.Equal("xmlReaders",
                         Assert.Throws <ArgumentNullException>(
                             () => EdmItemCollection.Create(null, null, out errors)).ParamName);
        }
Example #3
0
        public void EdmItemCollection_Create_factory_method_returns_EdmItemCollection_instance_for_valid_csdl()
        {
            var csdl =
                XDocument.Parse(
                    "<Schema Namespace='Model' p1:UseStrongSpatialTypes='false' " +
                    "  xmlns:p1='http://schemas.microsoft.com/ado/2009/02/edm/annotation' " +
                    "  xmlns='http://schemas.microsoft.com/ado/2009/11/edm'>" +
                    "  <EnumType Name='Color' />" +
                    "</Schema>");

            IList <EdmSchemaError> errors;
            var edmItemCollection = EdmItemCollection.Create(new[] { csdl.CreateReader() }, null, out errors);

            Assert.NotNull(edmItemCollection);
            Assert.NotNull(edmItemCollection.GetItem <EnumType>("Model.Color"));
            Assert.Equal(0, errors.Count);
        }
Example #4
0
        public void EdmItemCollection_Create_factory_method_returns_null_and_errors_for_invalid_csdl()
        {
            var csdl =
                XDocument.Parse(
                    "<Schema Namespace='Model' p1:UseStrongSpatialTypes='false' " +
                    "  xmlns:p1='http://schemas.microsoft.com/ado/2009/02/edm/annotation' " +
                    "  xmlns='http://schemas.microsoft.com/ado/2009/11/edm'>" +
                    "  <EnumType Name='Invalid Name' />" +
                    "</Schema>");

            IList <EdmSchemaError> errors;
            var edmItemCollection = EdmItemCollection.Create(new[] { csdl.CreateReader() }, null, out errors);

            Assert.Null(edmItemCollection);
            Assert.Equal(1, errors.Count);
            Assert.Contains("Invalid Name", errors[0].Message);
        }