Ejemplo n.º 1
0
        [Test] public void ifrs_Parse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_2004_06_15 s = new TestTaxonomy_2004_06_15();

            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);
            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);

            TimeSpan level = new TimeSpan(0, 0, 0, 10, 0);                      // 10 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long");

            PresentationLink pl = s.presentationInfo["Accounting Policies"] as PresentationLink;

            Assert.IsNotNull(pl);
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
0
        public void CheckOrderDiffPriority()
        {
            PresentationLocator parent = new TestPresentationLocator("parent", "xsd#parent");
            ArrayList           errors = new ArrayList();

            parent.ParseHRef(errors);
            Assert.AreEqual(0, errors.Count);

            PresentationLocator child  = new TestPresentationLocator("child", "xsd#child");
            PresentationLocator child2 = new TestPresentationLocator("child2", "xsd#child2");

//			PresentationLocator child3	= new TestPresentationLocator( "child_7.0_pro", "xsd#child" );

            child.ParseHRef(errors);
            //child.MyElement = new Element( "child_1.7", false );
            Assert.AreEqual(0, errors.Count);

            child2.ParseHRef(errors);
            //child2.MyElement = new Element( "child_7.0_opt", false );
            Assert.AreEqual(0, errors.Count);

            //child3.ParseHRef( errors );
            //child3.MyElement = new Element( "child_7.0_pro", false );
            //Assert.AreEqual( 0, errors.Count );

            PresentationLink pl = new PresentationLink("Test", "Test", new ArrayList());

            pl.AddLocator(parent);
            pl.AddLocator(child);
            pl.AddLocator(child2);

            parent.AddChild(child, "Label", "0", 1.7F, "label", "0", false);
            parent.AddChild(child, "Label", "0", 7.0F, "label", "0", false);
            parent.AddChild(child, "Label", "2", 7.0F, "label", "0", true);

            parent.AddChild(child2, "Label", "0", 2.0F, "label", "0", false);

//			pl.AddLocator( child3 );

            Node n = parent.CreateNode("en", "", "", pl);

            //should be:
            //	child (1.7)
            //	child2 (2.0)
            //  child - prohibited (7.0)

            Assert.AreEqual("parent", n.Label, "parent expected");
            Assert.AreEqual("child", ((Node)n.Children[0]).Label, "child 0 wrong");
            Assert.AreEqual("child2", ((Node)n.Children[1]).Label, "child 1 wrong");

            Assert.AreEqual(3, n.Children.Count, "wrong number of children");
            Assert.AreEqual("child", ((Node)n.Children[2]).Label, "child 2 wrong");

            Assert.IsFalse(((Node)n.Children[0]).IsProhibited, "child 0 is not prohibited");
            Assert.IsFalse(((Node)n.Children[1]).IsProhibited, "child 1 is not prohibited");
            Assert.IsTrue(((Node)n.Children[2]).IsProhibited, "child 2 is  prohibited");
        }
Ejemplo n.º 4
0
        public void MS_RoleTest()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_MS s = new TestTaxonomy_MS();

            int errors = 0;

            if (s.Load(MS_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.LoadImports(out errors);

            Assert.AreEqual(0, errors, "load imports failed");

            // loads the presentation linkbase for this taxonomy and merges the dependant taxonomy presentation linkbases
            errors = 0;
            s.LoadPresentation(out errors);

//			s.Parse( out errors );
//
            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
                SendWarningsToConsole(s.errorList);
            }
            Assert.AreEqual(0, errors, "load presentation failed");

            errors = 0;
            s.LoadElements(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
                //				//SendWarningsToConsole( s.errorList );
            }

            Assert.AreEqual(0, errors, "load elements failed");

            s.BindPresentationCalculationElements(true, out errors);

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/2003/role/link"] as PresentationLink;

            Assert.IsNotNull(pl, "can't get http://www.xbrl.org/2003/role/link");

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

            Assert.AreEqual(7, parentNode.Children.Count, "wrong number of children");
        }
Ejemplo n.º 5
0
        public void GAAP_Parse()
        {
            TestTaxonomy_2005_02_28 s = new TestTaxonomy_2005_02_28();
            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);

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

            Assert.IsNotNull(pl, "presentation link not found");

            Assert.IsNotNull(pl.BaseSchema, "PresentationLink BaseSchema is null");
            Assert.AreEqual("http://www.xbrl.org/us/fr/gaap/ci/2005-02-28/us-gaap-ci-2005-02-28.xsd", pl.BaseSchema, "BaseSchema wrong");

            PresentationLocator ploc = null;

            Assert.IsTrue(pl.TryGetLocator("usfr-pte_NetIncreaseDecreaseCashCashEquivalents", out ploc));

            Assert.AreEqual(0, errors, "parse failure");

            if (s.numWarnings > 0)
            {
                Assert.AreEqual(s.numWarnings, SendWarningsToConsole(s.errorList), "numWarnings doesn't match warnings reported in the errorList");
            }

            Assert.AreEqual(0, s.numWarnings, "wrong number of warnings ");

            // 57 = bind failures - elements w/o presentation

            //Trace.Listeners.Clear();
            TimeSpan level = new TimeSpan(0, 0, 0, 5, 0);               // 5 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long - " + (end - start) + " seconds");
        }
Ejemplo n.º 6
0
        public void MS_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_MS s = new TestTaxonomy_MS();

            int errors = 0;

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

            Assert.AreEqual(0, errors, "parse failed");

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/2003/role/link"] as PresentationLink;

            Assert.IsNotNull(pl, "can't get http://www.xbrl.org/2003/role/link");

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

            Assert.AreEqual(7, parentNode.Children.Count, "wrong number of children");

//			parentNode.Children.Sort();
//
//			Node earningsReleaseNode = parentNode.Children[13] as Node;
//
//			string text = null;
//			earningsReleaseNode.MyElement.TryGetLabel( "en", "label", out text );
//			Assert.AreEqual( "Earnings Release", text, "TryGetLabel wrong" );
//
//			Assert.AreEqual( "Earnings Release", earningsReleaseNode.Label, "label wrong" );
//
//			Node earningsReleaseText = earningsReleaseNode.Children[0] as Node;
//
//			earningsReleaseText.TryGetLabel( "en", "label", out text );
//			Assert.AreEqual( "Earnings Release Text", text, "Earnings Release Text label is wrong" );
        }
Ejemplo n.º 7
0
        public void PFS_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_CA_GAAP_PFS s = new TestTaxonomy_CA_GAAP_PFS();

            int errors = 0;

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

            // duplicate elements
            Assert.AreEqual(0, errors, "parse failed due to bad reference loader errors");

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/2003/role/link"] as PresentationLink;

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

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

            System.Text.StringBuilder sb = TestTaxonomy_EDGAROnline.DisplayNode(parentNode, 0);
            Console.WriteLine(sb.ToString());
            Assert.AreEqual(2, parentNode.Children.Count, "wrong number of children");

            // these names don't match the data they contain
            Node quarterlyReporting = parentNode.Children[1] as Node;
            Node MLA002             = quarterlyReporting.Children[0] as Node;

            Assert.AreEqual("Balance Sheet", MLA002.Label, "Node.Label on node MLA002 wrong");

            string references = null;

            Assert.IsTrue(MLA002.TryGetReferences(out references), "could not get references for MLA002");
            Assert.IsNotNull(references, "references is null");
        }
Ejemplo n.º 8
0
        [Test] public void IFRS_Parse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_IFRS_2004_06_15 s = new TestTaxonomy_IFRS_2004_06_15();

            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
                //SendWarningsToConsole( s.errorList );
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);

            TimeSpan level = new TimeSpan(0, 0, 0, 4, 0);               // 4 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long");

            PresentationLink pl = s.presentationInfo["http://xbrl.iasb.org/int/fr/ifrs/gp/role/BalanceSheetClassified"] as PresentationLink;

            Assert.IsNotNull(pl, "can't find Balance Sheet, Classified Format");

            PresentationLocator ploc = null;

            Assert.IsTrue(pl.TryGetLocator("ifrs-gp_HedgingInstrumentsNonCurrentLiability", out ploc));

            // problem with presentation linkbase - don't know the solution yet
            Assert.AreEqual(0, errors, "parse failure");
            Assert.AreEqual(0, s.numWarnings, "wrong number of warnings ");

            // 1712 = calculation warnings

            //Trace.Listeners.Clear();
        }
Ejemplo n.º 9
0
        public void BASI_Parse()
        {
            TestTaxonomy_2004_08_15 s = new TestTaxonomy_2004_08_15();
            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);



            DateTime end = DateTime.Now;

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }
            Console.WriteLine("Parse Time: {0}", end - start);

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

            Assert.IsNotNull(pl, "presentation link not found");

            PresentationLocator ploc = null;

            Assert.IsTrue(pl.TryGetLocator("usfr-pt_NetIncreaseDecreaseCashCashEquivalents", out ploc));

            Assert.AreEqual(0, errors, "parse failure");

            // 1 - duplicate element
            if (s.numWarnings > 7)
            {
                Assert.AreEqual(s.numWarnings, SendWarningsToConsole(s.errorList), "numWarnings doesn't match warnings reported in the errorList");
            }

            Assert.AreEqual(7, s.numWarnings, "wrong number of warnings ");

            TimeSpan level     = new TimeSpan(0, 0, 0, 8, 0);           // 8 seconds to parse
            TimeSpan timeTaken = end - start;

            Assert.IsTrue(level > timeTaken, "Parse takes too long - " + timeTaken.ToString() + " seconds");
        }
Ejemplo n.º 10
0
        private Axis BuildPresentationAxis(PresentationLink presentationLink)
        {
            var rootNodes = presentationLink.GetRootNodes();

            // The IFRS taxonomy only has single roots as a workaround for the shortcoming of XBRL that the order of root nodes
            // is undefined.
            if (rootNodes.Count > 1)
            {
                throw new InvalidOperationException($"The presentation network {presentationLink.Role} has multiple root nodes. This should not be the case for IFRS taxonomies.");
            }

            var rootMembers   = rootNodes.Select(n => TraversePresentationNetwork(n, null, new HashSet <XName>())).ToList();
            var axisNamespace = (XNamespace)presentationLink.Role.ToString();

            return(new Axis(Dimension.ConceptDimension, axisNamespace + "Axis", rootMembers));
        }
Ejemplo n.º 11
0
        public void Gemma_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_Gemma s = new TestTaxonomy_Gemma();

            int errors = 0;

            DateTime start = DateTime.Now;

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

            // duplicate elements
            Assert.AreEqual(0, errors, "parse failed due to bad reference loader errors");

            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);
            TimeSpan level = new TimeSpan(0, 0, 0, 5, 0);               // 5 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long");

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/2003/role/link"] as PresentationLink;

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

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

            Assert.AreEqual(1, parentNode.Children.Count, "wrong number of children");
        }
Ejemplo n.º 12
0
        [Test] public void GAAP_Parse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_2004_06_15 s = new TestTaxonomy_2004_06_15();

            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);
            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);

            TimeSpan level = new TimeSpan(0, 0, 0, 4, 0);               // 4 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long");

            PresentationLink pl = s.presentationInfo["Statement of Cash Flows - Direct Method - CI"] as PresentationLink;

            Assert.IsNotNull(pl);

            PresentationLocator ploc = null;

            Assert.IsTrue(pl.TryGetLocator("usfr-pt_NetIncreaseDecreaseCashCashEquivalents", out ploc));

            Assert.AreEqual(22 + 690 + 5 + 4 + 5 + 953 + 1474, errors, "parse failure");

            // 22 = presentation load errors
            // 690 = bind failures - elements w/o presentation
            // 5 = imports - 5 duplicate elements
            // 4 = duplicate labels
            // 5 = elements without matching labels
            // 953 = elements without ref
            // 1474 = element without calc

            //Trace.Listeners.Clear();
        }
Ejemplo n.º 13
0
        [Test] public void GAAP_Parse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_2004_07_06 s = new TestTaxonomy_2004_07_06();

            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);
            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);

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

            Assert.IsNotNull(pl, "presentation link is null");

            PresentationLocator ploc = null;

            Assert.IsTrue(pl.TryGetLocator("usfr-pt_NetIncreaseDecreaseCashCashEquivalents", out ploc));

            // problem with presentation linkbase - don't know the solution yet
            Assert.AreEqual(5, errors, "parse failure");

            Assert.AreEqual(2, s.numWarnings, "wrong number of warnings");
            // 2 = duplicate labels

            //Trace.Listeners.Clear();

            TimeSpan level = new TimeSpan(0, 0, 0, 4, 0);               // 4 seconds to parse

            Assert.IsTrue(level > (end - start), "Parse takes too long");
        }
Ejemplo n.º 14
0
        public void EDGAROnline_LoadAndParsePresentation()
        {
            TestTaxonomy_EDGAROnline s = new TestTaxonomy_EDGAROnline();
            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;

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

            // there should be 1 error because there's a presentation arc that would create an infinite recursion
            Assert.AreEqual(1, errors, "wrong number of errors in presentation");

            //s.ErrorList.Sort();

            Console.WriteLine(((ParserMessage)s.ErrorList[0]).Message);

            DateTime end = DateTime.Now;

            Console.WriteLine("Parse Time: {0}", end - start);
            TimeSpan level = new TimeSpan(0, 0, 0, 10, 0);                      // 10 seconds to parse

            Assert.AreEqual(9, s.presentationInfo.Count, "wrong number of presentation links");
            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/us/fr/lr/role/IncomeStatement"] as PresentationLink;

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

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

            Assert.AreEqual(2, parentNode.Children.Count, "wrong number of children in presentation");
            Assert.IsTrue(level > (end - start), "Parse takes too long - " + (end - start) + " seconds");
        }
Ejemplo n.º 15
0
        public void EDGAROnline_LoadAndParseCalculation()
        {
            for (int i = 0; i < 10; i++)
            {
                TestTaxonomy_EDGAROnline s = new TestTaxonomy_EDGAROnline();
                int errors = 0;

                DateTime start = DateTime.Now;
                if (s.Load(EDGARONLINE_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);

                // there should be 2 error because there's a calculation arc that would create an infinite recursion
                Assert.AreEqual(1, errors, "wrong number of errors in calculation");

                DateTime end = DateTime.Now;
                Console.WriteLine("Parse Time: {0}", end - start);
                TimeSpan level = new TimeSpan(0, 0, 0, 10, 0);                          // 10 seconds to parse
                Assert.AreEqual(10, s.calculationInfo.Count, "wrong number of calculation links");
                PresentationLink cl = s.calculationInfo["http://www.xbrl.org/us/fr/lr/role/CashFlowOperationsDirect"] as PresentationLink;
                Assert.IsNotNull(cl, "can't get http://www.xbrl.org/us/fr/lr/role/CashFlowOperationsDirect from calculation");

                Node parentNode = cl.CreateNode("en", "label");
                Assert.AreEqual(1, parentNode.Children.Count, "wrong number of children in calculation");

                s.currentLabelRole = @"preferredLabel";
                s.currentLanguage  = @"en";
                ArrayList temp = s.GetNodesByCalculation();

                Assert.IsTrue(level > (end - start), "Parse takes too long - " + (end - start) + " seconds");
            }
        }
Ejemplo n.º 16
0
        public void BASI_LabelTest()
        {
            TestTaxonomy_2005_02_28 s = new TestTaxonomy_2005_02_28();
            int errors = 0;

            DateTime start = DateTime.Now;

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

            errors = 0;
            s.Parse(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            s.BindPresentationCalculationElements(true, out errors);
            s.BindElements(new BindElementDelegate(s.BindLabelToElement), out errors);

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

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

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

            System.Text.StringBuilder sb = TestTaxonomy_EDGAROnline.DisplayNode(parentNode, 0);
            Console.WriteLine(sb.ToString());

            // test the fourth child
            Node n = (Node)parentNode.Children[13];

            Assert.AreEqual(n.Label, "Contingencies - Possible Loss", "label wrong");
        }
Ejemplo n.º 17
0
        private Linkbase CreatePresentationLinkbase(Taxonomy taxonomy, DiscoverableTaxonomySet dts)
        {
            var conceptItems = ExtensionItems.OfType <ExtensionConcept>().ToList(); // Does that include abstracts?

            var linkbase = new Linkbase(GetLinkbaseFileName(taxonomy, "pre"));

            var groupedByNetworkRole = conceptItems.SelectMany(i => i.Locations.Select(l =>
                                                                                       new { l.NetworkRole, Location = l, Item = i }))
                                       .GroupBy(d => d.NetworkRole)
                                       .ToList();

            foreach (var groupByNetworkRole in groupedByNetworkRole)
            {
                var presentationLink = new PresentationLink(LinkbaseXNames.Presentation, groupByNetworkRole.Key);
                linkbase.AddLink(presentationLink, dts);

                var locCount = 0;
                foreach (var locationAndItem in groupByNetworkRole)
                {
                    var parentItem = dts.FindItem(locationAndItem.Location.ParentName);
                    if (parentItem == null)
                    {
                        throw new InvalidOperationException($"There is no concept {locationAndItem.Location.ParentName} in the DTS.");
                    }

                    var parentLocatorNodes = parentItem.Nodes
                                             .Where(n => n.Link.Role == groupByNetworkRole.Key).ToList();
                    if (!parentLocatorNodes.Any())
                    {
                        throw new InvalidOperationException($"The concept {locationAndItem.Location.ParentName} is not in the presentation network {groupByNetworkRole.Key}.");
                    }

                    var siblingArcs = parentLocatorNodes.First().GetOrderedOutgoingHierarchicalArcs <PresentationArc>();

                    double newOrder;
                    try
                    {
                        newOrder = DetermineOrder(locationAndItem.Location.PrecedingSiblingName, siblingArcs);
                    }
                    catch (InvalidOperationException ex)
                    {
                        throw new InvalidOperationException($"The sibling {locationAndItem.Location.PrecedingSiblingName} was not found as a child of {locationAndItem.Location.ParentName} in the presentation network {groupByNetworkRole.Key}.", ex);
                    }

                    var parentLocLabel = $"loc_{locCount}";
                    locCount += 1;
                    var parentNode = new LocatorNode(parentLocLabel, parentItem);
                    presentationLink.AddNode(parentNode);

                    var childLocLabel = $"loc_{locCount}";
                    locCount += 1;
                    var childNode = CreateLocatorNode(childLocLabel, locationAndItem.Item, dts);
                    presentationLink.AddNode(childNode);

                    var arc = new PresentationArc(parentNode, childNode, newOrder, locationAndItem.Location.PreferredLabelRole);
                    presentationLink.AddArc(arc);
                }
            }

            return(linkbase);
        }
Ejemplo n.º 18
0
        public void GAAP_TestDependantPresentations()
        {
            TestTaxonomy_2005_02_28 s = new TestTaxonomy_2005_02_28();
            int errors = 0;

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

            s.LoadImports(out errors);
            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            s.LoadPresentation(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            if (s.numWarnings > 0)
            {
                SendWarningsToConsole(s.errorList);
                SendInfoToConsole(s.errorList);
            }

            errorList.Clear();
            errors = s.numWarnings = 0;
            s.LoadElements(out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            if (s.numWarnings > 0)
            {
                SendWarningsToConsole(s.errorList);
                SendInfoToConsole(s.errorList);
            }

            // and now bind elements to presentation
            errorList.Clear();
            errors = s.numWarnings = 0;
            s.BindPresentationCalculationElements(true, out errors);

            if (errors > 0)
            {
                SendErrorsToConsole(s.errorList);
            }

            if (s.numWarnings > 0)
            {
                SendWarningsToConsole(s.errorList);
                SendInfoToConsole(s.errorList);
            }

            // ok, now do some testing
            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/us/fr/lr/role/StatementFinancialPosition"] as PresentationLink;

            Assert.IsNotNull(pl, "Presentation link is null");

            PresentationLocator presLocator = null;

            pl.TryGetLocator("usfr-pte_CommonStockShareSubscriptions", out presLocator);

            Assert.IsNotNull(presLocator, "presentation Locator not found");
        }
Ejemplo n.º 19
0
        public void FSA_5_LoadAndParse()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );

            TestTaxonomy_FSA s = new TestTaxonomy_FSA();

            int errors = 0;

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

            // duplicate elements
            Assert.AreEqual(0, errors, "parse failed");

            PresentationLink pl = s.presentationInfo["http://www.xbrl.org/2003/role/link"] as PresentationLink;

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

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

            Assert.AreEqual(2, parentNode.Children.Count, "wrong number of children");

            parentNode.Children.Sort();

//			Node quarterlyReporting = null;
//			Node MLA002 = null;
//
//			foreach( Node node in parentNode.Children )
//			{
//				if( node.Label == "SECTION A: Balance sheet")
//				{
//					MLA002 = node;
//				}
//				else
//				{
//					quarterlyReporting = node;
//				}
//			}
            Node quarterlyReporting = parentNode.Children[1] as Node;
            Node MLA002             = quarterlyReporting.Children[0] as Node;


            Assert.AreEqual("SECTION A: Balance sheet", MLA002.Label, "Node.Label on node MLA002 wrong");

            string text = null;

            MLA002.MyElement.TryGetLabel("en", "definitionGuidance", out text);
            Assert.AreEqual(1925, text.Length, "TryGetLabel on node MLA002 wrong");

            string references = null;

            Assert.IsTrue(MLA002.TryGetReferences(out references), "could not get references for MLA002");
            Assert.IsNotNull(references, "references is null");
        }