Example #1
0
        public void OM_20060430_FILE_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();

            int errors = 0;

            if (s.Load(OM_20060430_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);

            // 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, "wrong number of errors");
            // 1 duplicate element
            Element RepurchaseAgreementsTuple = s.AllElements["usfr-ime_RepurchaseAgreementsTuple"] as Element;

            Assert.IsNotNull(RepurchaseAgreementsTuple, "Failed to find RepurchaseAgreementsTuple");

            Assert.IsTrue(RepurchaseAgreementsTuple.HasChildren, "RepurchaseAgreementsTuple does nothave any children");
        }
Example #2
0
        public void Test_ExtendedTupleLabelsResolution()
        {
            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();

            int    errors   = 0;
            string fileName = TestCommon.FolderRoot + @"faif-20071031" + System.IO.Path.DirectorySeparatorChar + "faif-20071031.xsd";

            if (s.Load(fileName, 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);

            // 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);
            }
            s.CurrentLabelRole = PresentationLocator.preferredLabelRole;
            s.CurrentLanguage  = "en";


            ArrayList nodes = s.GetNodesByPresentation();

            ArrayList flatList = new ArrayList();

            GetFlatListOfPresentationNodes(nodes, ref flatList);

            Hashtable expectedValues = new Hashtable();

            expectedValues["usfr-ime_InvestmentDescription"]  = "Investment Description";
            expectedValues["usfr-ime_NumberContracts"]        = "Number of Contracts";
            expectedValues["usfr-ime_ContractsHeldLongShort"] = "Are Contracts Held Long or Short?";
            expectedValues["usfr-ime_ExpirationDate"]         = "Expiration Date";
            expectedValues["usfr-ime_FaceValue"] = "Face Value";
            expectedValues["usfr-ime_FuturesContractUnrealizedAppreciationDepreciation"] = "Futures Contract - Unrealized Appreciation/(Depreciation)";
            expectedValues["faif_NotionalContractValue"] = "Notional Contract Value";

            foreach (Node n in flatList)
            {
                if (n.parent != null && n.parent.Id == "faif_FuturesListingTuple")
                {
                    Console.WriteLine(n.Label);
                    if (expectedValues[n.Id] != null)
                    {
                        Assert.AreEqual(expectedValues[n.Id], n.Label);
                    }
                    else
                    {
                        Assert.Fail("Failed to find child " + n.Id);
                    }
                }
            }
        }
Example #3
0
        public void IM_LoadAndParse()
        {
            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();
            int errors = 0;

            if (s.Load(IM_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);

            // 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, "parse failed");
            // 1 duplicate element

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/us/fr/lr/role/PortfolioInvestments"] as PresentationLink;

            Assert.IsNotNull(pl, "can't get http://www.xbrl.org/us/fr/lr/role/PortfolioInvestments");

            Node parentNode = pl.CreateNode("en", "Label");

            Assert.AreEqual(1, parentNode.Children.Count, "wrong number of children");
        }
        public void IM_2005_06_28_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();

            int errors = 0;

            if ( s.Load( IM_2005_06_28_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 );

            // 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, "wrong number of errors" );
            // 1 duplicate element
            Element RepurchaseAgreementsTuple = s.AllElements["usfr-ime_RepurchaseAgreementsTuple"] as Element;

            Assert.IsNotNull(RepurchaseAgreementsTuple, "Failed to find RepurchaseAgreementsTuple");

            Assert.IsTrue(RepurchaseAgreementsTuple.HasChildren, "RepurchaseAgreementsTuple does nothave any children");
        }
Example #5
0
        public void IM_2005_06_28_TestBoolean()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();
            int errors = 0;

            if (s.Load(IM_2005_06_28_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);

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

            // usfr-ime_AffiliatedCompany is boolean type
            Element e = s.allElements["usfr-ime_AffiliatedCompany"] as Element;

            Assert.IsNotNull(e, "usfr-ime_AffiliatedCompany element not found");

            Enumeration enumer = s.enumTable["xbrli:booleanItemType"] as Enumeration;

            Assert.IsNotNull(enumer);

            Assert.IsNotNull(e.EnumData, "no enumeration data");
            Assert.AreEqual(2, e.EnumData.Values.Count, "wrong number of enumerations");
            Assert.AreEqual("Yes", e.EnumData.Values[0], "wrong enumeration at index 0");
            Assert.AreEqual("No", e.EnumData.Values[1], "wrong enumeration at index 1");
        }
        public void Test_ExtendedTupleLabelsResolution()
        {
            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();

            int errors = 0;
            string fileName = TestCommon.FolderRoot + @"faif-20071031" + System.IO.Path.DirectorySeparatorChar + "faif-20071031.xsd";
            if (s.Load(fileName, 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);

            // 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);
            }
            s.CurrentLabelRole = PresentationLocator.preferredLabelRole;
            s.CurrentLanguage = "en";

            ArrayList nodes =   s.GetNodesByPresentation();

            ArrayList flatList = new ArrayList();
            GetFlatListOfPresentationNodes(nodes, ref flatList);

            Hashtable expectedValues = new Hashtable();
            expectedValues["usfr-ime_InvestmentDescription"] = "Investment Description";
            expectedValues["usfr-ime_NumberContracts"] = "Number of Contracts";
            expectedValues["usfr-ime_ContractsHeldLongShort"] = "Are Contracts Held Long or Short?";
            expectedValues["usfr-ime_ExpirationDate"] = "Expiration Date";
            expectedValues["usfr-ime_FaceValue"] = "Face Value";
            expectedValues["usfr-ime_FuturesContractUnrealizedAppreciationDepreciation"] = "Futures Contract - Unrealized Appreciation/(Depreciation)";
            expectedValues["faif_NotionalContractValue"] = "Notional Contract Value";

            foreach (Node n in flatList)
            {
                if (n.parent != null && n.parent.Id == "faif_FuturesListingTuple")
                {
                    Console.WriteLine(n.Label);
                    if (expectedValues[n.Id] != null)
                    {
                        Assert.AreEqual(expectedValues[n.Id], n.Label);

                    }
                    else
                    {
                        Assert.Fail("Failed to find child " + n.Id);
                    }
                }

            }
        }
        public void IM_LoadAndParse()
        {
            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();
            int errors = 0;

            if ( s.Load( IM_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 );

            // 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, "parse failed" );
            // 1 duplicate element

            PresentationLink pl = s.presentationInfo[ "http://www.xbrl.org/us/fr/lr/role/PortfolioInvestments" ] as PresentationLink;
            Assert.IsNotNull( pl, "can't get http://www.xbrl.org/us/fr/lr/role/PortfolioInvestments" );

            Node parentNode = pl.CreateNode( "en", "Label" );
            Assert.AreEqual(1, parentNode.Children.Count, "wrong number of children" );
        }
        public void IM_2005_06_28_TestBoolean()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_US_GAAP_IM s = new TestTaxonomy_US_GAAP_IM();
            int errors = 0;

            if ( s.Load( IM_2005_06_28_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 );

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

            // usfr-ime_AffiliatedCompany is boolean type
            Element e = s.allElements["usfr-ime_AffiliatedCompany"] as Element;
            Assert.IsNotNull( e, "usfr-ime_AffiliatedCompany element not found" );

            Enumeration enumer = s.enumTable["xbrli:booleanItemType"] as Enumeration;
            Assert.IsNotNull( enumer );

            Assert.IsNotNull (e.EnumData, "no enumeration data" );
            Assert.AreEqual( 2, e.EnumData.Values.Count, "wrong number of enumerations" );
            Assert.AreEqual( "Yes", e.EnumData.Values[0], "wrong enumeration at index 0" );
            Assert.AreEqual( "No", e.EnumData.Values[1], "wrong enumeration at index 1" );
        }
Example #9
0
        public void Dow_ParseUsingCloneOfBaseTaxonomy()
        {
            DateTime start = DateTime.Now;

            DOW_LoadAndParse();

            DateTime end = DateTime.Now;

            Console.WriteLine("TIME TAKEN TO LOAD WITHOUT CACHE = {0}", end - start);

            string US_GAAP_FILE = TestCommon.FolderRoot + @"XBRL 2.1 Updated" + System.IO.Path.DirectorySeparatorChar + "2005-02-28" + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd";

            Taxonomy bt = new Taxonomy();

            bt.Load(US_GAAP_FILE);



            int errors = 0;

            bt.Parse(out errors);

            bt.CurrentLabelRole = "Label";
            bt.CurrentLanguage  = "en";
            ArrayList nodeList = bt.GetNodesByPresentation();


            MemoryStream    msWrite        = new MemoryStream();
            BinaryFormatter formatterWrite = new BinaryFormatter();

            formatterWrite.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
            formatterWrite.Serialize(msWrite, bt);

            byte[] bufOrig = msWrite.GetBuffer();

            ArrayList flatListOrig = new ArrayList();

            TestTaxonomy_US_GAAP_IM.GetFlatListOfPresentationNodes(nodeList, ref flatListOrig);
            Hashtable taxIdInfos = new Hashtable();

            for (int i = 0; i < flatListOrig.Count; i++)
            {
                Node orig = flatListOrig[i] as Node;

                if (orig.MyElement != null)
                {
                    taxIdInfos[orig.Id] = orig.MyElement.TaxonomyInfoId;
                }
            }

            taxonomyCache[Path.GetFileName(US_GAAP_FILE)] = bt;


            Taxonomy.TaxonomyCacheManager = this;


            start = DateTime.Now;

            DOW_LoadAndParse();

            end = DateTime.Now;

            Console.WriteLine("TIME TAKEN TO LOAD WITH CACHE = {0}", end - start);

            ArrayList nodeListAfter = bt.GetNodesByPresentation();

            ArrayList flatListAfter = new ArrayList();

            TestTaxonomy_US_GAAP_IM.GetFlatListOfPresentationNodes(nodeListAfter, ref flatListAfter);



            Assert.AreEqual(flatListOrig.Count, flatListAfter.Count, "should not change");

            for (int i = 0; i < flatListAfter.Count; i++)
            {
                Node orig  = flatListOrig[i] as Node;
                Node after = flatListAfter[i] as Node;


                Assert.AreEqual(orig.Label, after.Label, "Label should match");

                Assert.AreEqual(orig.Id, after.Id);
                if (after.MyElement != null)
                {
                    Assert.AreEqual(taxIdInfos[after.Id], after.MyElement.TaxonomyInfoId);
                }
            }

            Taxonomy.TaxonomyCacheManager = null;

            msWrite        = new MemoryStream();
            formatterWrite = new BinaryFormatter();
            formatterWrite.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
            formatterWrite.Serialize(msWrite, bt);

            byte[] bufAfter = msWrite.GetBuffer();

            Assert.AreEqual(bufOrig.Length, bufAfter.Length, "Cache object has changed");



            MemoryStream    msRead        = new MemoryStream(bufOrig);
            BinaryFormatter formatterRead = new BinaryFormatter();

            formatterRead.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
            Taxonomy origbt = formatterRead.Deserialize(msRead) as Taxonomy;


            Assert.AreEqual(origbt.AllElements.Count, bt.AllElements.Count);



            //for( int i = 0 ;i < bufAfter.Length ; i++ )
            //{
            //    if (bufAfter[i] != bufOrig[i])
            //    {
            //        Console.WriteLine("Position that is not correct = {0} out of total = {1}" ,i, bufAfter.Length);
            //    }
            //    Assert.AreEqual(bufAfter[i], bufOrig[i], "binary data is different");
            //}
        }