<commit_before>﻿//#define local
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Xml;
using NUnit.Framework;
//using System.Net.Http;


namespace OData2Poco.Tests
{

    [TestFixture]
    public partial class MetaDataReaderTests
    {
        [Test]
        [TestCase("http://services.odata.org/V4/OData/OData.svc")] //v4
        [TestCase("http://services.odata.org/V3/OData/OData.svc")] //v3
        [TestCase(@"data\northwindV4.xml")] //filename 
        [TestCase(@"data\northwindV3.xml")]
        public void ReadMetaDataAsStringTest(string url)
        {
            var metaDataReader = new MetaDataReader(url);
            var meta = metaDataReader.MetaDataAsString;
            Assert.IsNotEmpty(meta);
            var meta2 = metaDataReader.MetaDataAsString;
            Assert.IsNotEmpty(meta2);
        }

        [Test]
        [TestCase("http://services.odata.org/V4/OData/OData.svc", "4.0")] //v4
        [TestCase("http://services.odata.org/V3/OData/OData.svc", "1.0")] //v3
        [TestCase(@"data\northwindV4.xml", "4.0")] //filename 
        [TestCase(@"data\northwindV3.xml", "1.0")]
        public void ReadMetaDataVersionTest(string url, string serviceVersion)
        {
            var metaDataReader = new MetaDataReader(url);
            var version = metaDataReader.MetaDataVersion;
            Console.WriteLine(version);
            Assert.AreEqual(version, serviceVersion);
            //repeat operation
            var version2 = metaDataReader.MetaDataVersion;
            Console.WriteLine(version2);
            Assert.AreEqual(version2, serviceVersion);
        }

        [Test]
        [TestCase("http://services.odata.org/V4/OData/OData.svc", 11)] //v4
        [TestCase("http://services.odata.org/V3/OData/OData.svc", 11)] //v3
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileExecuteTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);
            var code = metaDataReader.Execute().ToString();
            Debug.WriteLine(code);
            //var code = gen.ToString();
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            StringAssert.Contains("public class FeaturedProduct", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase("http://services.odata.org/V4/OData/OData.svc", 11)] //v4
        [TestCase("http://services.odata.org/V3/OData/OData.svc", 11)] //v3
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileExecuteSettingTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);

            var code = metaDataReader.Execute(new PocoSetting
            {
                AddKeyAttribute = true,
                AddTableAttribute = true,
                AddRequiredAttribute = true,
                AddNullableDataType = true
            }).ToString();
            Debug.WriteLine(code);
            //var code = gen.ToString();
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            StringAssert.Contains("public class FeaturedProduct", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase("http://services.odata.org/V4/OData/OData.svc", 11)] //v4
        [TestCase("http://services.odata.org/V3/OData/OData.svc", 11)] //v3
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileGeneratorTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);
            var gen = metaDataReader.Generator; //.Execute();
            var code = gen.ToString();
            Console.WriteLine(code);
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            StringAssert.Contains("public class FeaturedProduct", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase("http://not_valid_url.com")] //not valid url
        [TestCase("http://www.google.com")] //not odata support
        public void GeneratePocoInvalidODataOrUrlTest(string url)
        {
            var code = "";
            var metaDataReader = new MetaDataReader(url);
            Assert.Throws<WebException>(() => code = metaDataReader.GeneratePoco());
            Assert.IsEmpty(code);
        }

#if local
        //test secured servers
        [Test]
        public void GeneratePocoWithValidAccountTes()
        {
            string url = "http://localhost/odata2/api/northwind";
            var metaDataReader = new MetaDataReader(url,"user","password");
            var code = metaDataReader.GeneratePoco();
            Assert.IsNotEmpty(code);

        }

<commit_msg>change unit test source data<commit_after>﻿//#define local
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Xml;
using NUnit.Framework;
//using System.Net.Http;


namespace OData2Poco.Tests
{
      

    [TestFixture]
    public partial class MetaDataReaderTests
    {
        const string UrlV4 = "http://services.odata.org/V4/Northwind/Northwind.svc";
        const string UrlV3 = "http://services.odata.org/V3/Northwind/Northwind.svc";
      

        [Test]
        [TestCase(UrlV4)]
        [TestCase(UrlV3)]
        [TestCase(@"data\northwindV4.xml")] //filename 
        [TestCase(@"data\northwindV3.xml")]
        public void ReadMetaDataAsStringTest(string url)
        {
            var metaDataReader = new MetaDataReader(url);
            var meta = metaDataReader.MetaDataAsString;
            Assert.IsNotEmpty(meta);
            var meta2 = metaDataReader.MetaDataAsString;
            Assert.IsNotEmpty(meta2);
        }

        [Test]
        [TestCase(UrlV4,"4.0")]
        [TestCase(UrlV3,"1.0")]
        [TestCase(@"data\northwindV4.xml", "4.0")] //filename 
        [TestCase(@"data\northwindV3.xml", "1.0")]
        public void ReadMetaDataVersionTest(string url, string serviceVersion)
        {
            var metaDataReader = new MetaDataReader(url);
            var version = metaDataReader.MetaDataVersion;
            Console.WriteLine(version);
            Assert.AreEqual(version, serviceVersion);
            //repeat operation
            var version2 = metaDataReader.MetaDataVersion;
            //Console.WriteLine(version2);
            Assert.AreEqual(version2, serviceVersion);
        }

        [Test]
        [TestCase(UrlV4, 26)]
        [TestCase(UrlV3, 26)]
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileExecuteTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);
            var code = metaDataReader.Execute().ToString();
            //Debug.WriteLine(code);
            //var code = gen.ToString();
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase(UrlV4, 26)]
        [TestCase(UrlV3, 26)]
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileExecuteSettingTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);

            var code = metaDataReader.Execute(new PocoSetting
            {
                AddKeyAttribute = true,
                AddTableAttribute = true,
                AddRequiredAttribute = true,
                AddNullableDataType = true
            }).ToString();
            //Debug.WriteLine(code);
            //var code = gen.ToString();
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase(UrlV4, 26)]
        [TestCase(UrlV3, 26)]
        [TestCase(@"data\northwindV4.xml", 11)] //filename , countof entities in the model
        [TestCase(@"data\northwindV3.xml", 11)]
        //expecteCount: count of classes /Entities
        public void GeneratePocoFromHttporFileGeneratorTest(string url, int expecteCount)
        {
            var metaDataReader = new MetaDataReader(url);
            var gen = metaDataReader.Generator; //.Execute();
            var code = gen.ToString();
            //Console.WriteLine(code);
            Assert.IsNotEmpty(code);
            StringAssert.Contains("public class Product", code);
            ////Assert.AreEqual(metaDataReader.ClassList.Count, expecteCount);
            Assert.AreEqual(metaDataReader.Generator.ClassDictionary.Count, expecteCount);
            //Assert.AreEqual(metaDataReader.Execute().ClassDictionary.Count, expecteCount);


        }

        [Test]
        [TestCase("http://not_valid_url.com")] //not valid url
        [TestCase("http://www.google.com")] //not odata support
        public void GeneratePocoInvalidODataOrUrlTest(string url)
        {
            var code = "";
            var metaDataReader = new MetaDataReader(url);
            Assert.Throws<WebException>(() => code = metaDataReader.GeneratePoco());
            Assert.IsEmpty(code);
        }

#if local
        //test secured servers
        [Test]
        public void GeneratePocoWithValidAccountTes()
        {
            string url = "http://localhost/odata2/api/northwind";
            var metaDataReader = new MetaDataReader(url,"user","password");
            var code = metaDataReader.GeneratePoco();
            Assert.IsNotEmpty(code);

        }


{'fraction_non_alphanumeric': 0.11910778077894921, 'fraction_numerical': 0.011501263396357934, 'mean_word_length': 2.3144672249494658, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1773012', 'n_tokens_mistral': 3237, 'n_tokens_neox': 3114, 'n_words': 586}