Exemplo n.º 1
0
        public void NTP2005_LoadAndParse()
        {
            TestTaxonomy_NTP s = new TestTaxonomy_NTP();

            int errors = 0;

            DateTime start = DateTime.Now;

            if (s.Load(NTP2005_FILE, out errors) != true)
            {
                Assert.Fail((string)s.ErrorList[0]);
            }

            errors = 0;

            // this loads up all dependant taxonomies, and loads the corresponding presentation, calculation, label, and reference linkbases
            s.Parse(out errors);

            DateTime end = DateTime.Now;

            // loads the presentation linkbase for this taxonomy and merges the dependant taxonomy presentation linkbases
            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            //			SendWarningsToConsole( s.errorList );
            //			SendInfoToConsole( s.ErrorList );

            Assert.AreEqual(0, errors, "errors returned from parse");

            DateTime getNodesStart = DateTime.Now;

            s.CurrentLabelRole = "preferredLabel";
            s.CurrentLanguage  = "en";
            ArrayList vals = s.GetNodesByPresentation();

            DateTime getNodesEnd = DateTime.Now;

            Console.WriteLine("Load and Parse: " + (end - start).ToString());
            Console.WriteLine("Show: " + (getNodesEnd - getNodesStart).ToString());

            //Verify that all elements have MyDataType set (extendeted data types converted to base types)
            int       naCount = 0;
            int       blankElementTypeCount = 0;
            Hashtable htMissingTypes        = new Hashtable(0);

            foreach (Element e1 in s.AllElements.Values)
            {
                if (e1.MyDataType.ToString().ToLower() == "na")
                {
                    if (e1.ElementType.Length == 0)
                    {
                        blankElementTypeCount += 1;
                    }
                    else
                    {
                        if (htMissingTypes[e1.ElementType] == null)
                        {
                            htMissingTypes[e1.ElementType] = 1;
                        }
                        else
                        {
                            int cnt = int.Parse(htMissingTypes[e1.ElementType].ToString());
                            htMissingTypes[e1.ElementType] = cnt + 1;
                        }
                    }
                    naCount += 1;
                }
            }

            Console.WriteLine("Total element do not have MyDataType = " + naCount.ToString());
            Console.WriteLine("no element type:" + blankElementTypeCount.ToString());
            foreach (string typeName in htMissingTypes.Keys)
            {
                Console.WriteLine(typeName + ":" + htMissingTypes[typeName].ToString());
            }

            Assert.AreEqual(731, naCount, "Incorrent number of [N/A] elements.");
            Assert.AreEqual(578, blankElementTypeCount, "Incorrent number of elements without Element Type specified.");
        }
Exemplo n.º 2
0
        public void NTP2005_LoadAndParse()
        {
            TestTaxonomy_NTP s = new TestTaxonomy_NTP();

            int errors = 0;

            DateTime start = DateTime.Now;
            if ( s.Load( NTP2005_FILE, out errors ) != true )
            {
                Assert.Fail( (string)s.ErrorList[0]);
            }

            errors = 0;

            // this loads up all dependant taxonomies, and loads the corresponding presentation, calculation, label, and reference linkbases
            s.Parse( out errors );

            DateTime end = DateTime.Now;

            // loads the presentation linkbase for this taxonomy and merges the dependant taxonomy presentation linkbases
            if ( errors > 0 )
            {
                SendErrorsToConsole( s.errorList );
            }

            //			SendWarningsToConsole( s.errorList );
            //			SendInfoToConsole( s.ErrorList );

            Assert.AreEqual( 0, errors, "errors returned from parse" );

            DateTime getNodesStart = DateTime.Now;

            s.CurrentLabelRole = "preferredLabel";
            s.CurrentLanguage = "en";
            ArrayList vals = s.GetNodesByPresentation();

            DateTime getNodesEnd = DateTime.Now;

            Console.WriteLine( "Load and Parse: " + (end-start).ToString() );
            Console.WriteLine( "Show: " + (getNodesEnd-getNodesStart).ToString() );

            //Verify that all elements have MyDataType set (extendeted data types converted to base types)
            int naCount = 0;
            int blankElementTypeCount = 0;
            Hashtable htMissingTypes = new Hashtable(0);

            foreach (Element e1 in s.AllElements.Values)
            {
                if (e1.MyDataType.ToString().ToLower() == "na")
                {

                    if (e1.ElementType.Length == 0)
                    {
                        blankElementTypeCount += 1;
                    }
                    else
                    {
                        if (htMissingTypes[e1.ElementType] == null)
                        {
                            htMissingTypes[e1.ElementType] = 1;
                        }
                        else
                        {
                            int cnt = int.Parse(htMissingTypes[e1.ElementType].ToString());
                            htMissingTypes[e1.ElementType] = cnt + 1;
                        }
                    }
                    naCount += 1;
                }

            }

            Console.WriteLine ("Total element do not have MyDataType = " + naCount.ToString());
            Console.WriteLine ("no element type:"+ blankElementTypeCount.ToString());
            foreach (string typeName in htMissingTypes.Keys)
            {
                Console.WriteLine (typeName + ":" + htMissingTypes[typeName].ToString());
            }

            Assert.AreEqual (731, naCount, "Incorrent number of [N/A] elements.");
            Assert.AreEqual (578, blankElementTypeCount, "Incorrent number of elements without Element Type specified.");
        }