Example #1
0
        public void DOW_LoadAndParse()
        {
            TestTaxonomy_DOW_20060331 s = new TestTaxonomy_DOW_20060331();

            int errors = 0;

            if (s.Load(DOW_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, "errors returned from parse");

            s.currentLanguage  = "en";
            s.currentLabelRole = "preferredLabel";

            ArrayList nodes = s.GetNodesByPresentation();

            Node statements = nodes[2] as Node;

            Assert.IsNotNull(statements, "statements is null");
            Assert.AreEqual("Income Statement", statements.Label, "node 3 wrong name");
            Assert.IsTrue(statements.ElementIsNull, "statements.MyElement is not null");

            Node statement = statements.Children[0] as Node;

            Assert.IsNotNull(statement, "statement is null");
            Assert.IsFalse(statement.ElementIsNull, "statement.MyElement is null");

            Node revenue = statement.Children[0] as Node;

            Assert.IsNotNull(revenue, "revenue is null");
            Assert.AreEqual("Revenue", revenue.Label, "revenue wrong name");
            Assert.AreEqual(5, revenue.Children.Count, "assets has wrong number of children");

            Node salesRevenueAbs = revenue.Children[0] as Node;

            Assert.IsNotNull(salesRevenueAbs, "salesRevenueAbs is null");
            Assert.AreEqual("Sales Revenue", salesRevenueAbs.Label, "revenue wrong name");
            Assert.AreEqual(4, salesRevenueAbs.Children.Count, "salesRevenueAbs has wrong number of children");

//			Node netSalesProhibited = salesRevenueAbs.Children[2] as Node;
//			Assert.IsNotNull( netSalesProhibited, "netSalesProhibited is null" );
//			Assert.IsTrue( netSalesProhibited.IsProhibited, "netSalesProhibited is not prohibited" );

            Node netSales = salesRevenueAbs.Children[2] as Node;

            Assert.IsNotNull(netSales, "netSales is null");
            Assert.IsFalse(netSales.IsProhibited, "netSales is prohibited");


            Node operationExpensesAbstract = statement.Children[3] as Node;

            Assert.IsNotNull(operationExpensesAbstract, "operationExpensesAbstract is null");
            Assert.AreEqual("Operating Expenses", operationExpensesAbstract.Label, "operationExpensesAbstract wrong name");
            Assert.AreEqual(12, operationExpensesAbstract.Children.Count, "operationExpensesAbstract has wrong number of children");

            Node rdExpenseAbs = operationExpensesAbstract.Children[0] as Node;

            Assert.IsNotNull(rdExpenseAbs, "rdExpenseAbs is null");
            Assert.AreEqual("Research and Development Expense", rdExpenseAbs.Label, "rdExpenseAbs wrong name");

            //old dragon tag bug.. we have the same element displaying twice one for order 3 and one for order 3.005
            Assert.AreEqual(6, rdExpenseAbs.Children.Count, "rdExpenseAbs has wrong number of children");

            Node rdExpenseEx = rdExpenseAbs.Children[0] as Node;

            Assert.IsNotNull(rdExpenseEx, "rdExpenseEx is null");
            Assert.AreEqual("Research and Development Expense (Excluding In - Process)", rdExpenseEx.Label, "rdExpenseEx wrong name");

            Node rdExpenseDev = rdExpenseAbs.Children[1] as Node;

            Assert.IsNotNull(rdExpenseDev, "rdExpenseDev is null");
            Assert.AreEqual("In - Process Research and Development", rdExpenseDev.Label, "rdExpenseDev wrong name");

            Node rdExpenseInc = rdExpenseAbs.Children[5] as Node;

            Assert.IsNotNull(rdExpenseInc, "rdExpenseInc is null");
            Assert.AreEqual("Research and development expenses", rdExpenseInc.Label, "rdExpenseInc wrong name");
            Assert.IsFalse(rdExpenseInc.IsProhibited, "rdExpenseInc is prohibited");

//			Node rdExpenseInc2 = rdExpenseAbs.Children[3] as Node;
//			Assert.IsNotNull( rdExpenseInc2, "rdExpenseInc2 is null" );
//			Assert.AreEqual( "Research and development expenses", rdExpenseInc2.Label, "rdExpenseInc2 wrong name" );
//			Assert.IsTrue( rdExpenseInc2.IsProhibited, "rdExpenseInc2 is not prohibited" );


            foreach (Element ele in s.allElements.Values)
            {
                TaxonomyItem ti = s.TaxonomyItems[ele.TaxonomyInfoId];
                Assert.IsNotNull(ti, "taxonomy item does not exist");

                if (!ele.Id.StartsWith(ti.Namespace))
                {
                    Assert.Fail("Failed to set the correct Taxonomy item id for element ");
                }
            }
        }
        public void DOW_LoadAndParse()
        {
            TestTaxonomy_DOW_20060331 s = new TestTaxonomy_DOW_20060331();

            int errors = 0;

            if ( s.Load( DOW_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, "errors returned from parse" );

            s.currentLanguage = "en";
            s.currentLabelRole = "preferredLabel";

            ArrayList nodes = s.GetNodesByPresentation();

            Node statements = nodes[2] as Node;
            Assert.IsNotNull( statements, "statements is null" );
            Assert.AreEqual( "Income Statement", statements.Label, "node 3 wrong name" );
            Assert.IsTrue( statements.ElementIsNull, "statements.MyElement is not null");

            Node statement = statements.Children[0] as Node;
            Assert.IsNotNull( statement, "statement is null" );
            Assert.IsFalse( statement.ElementIsNull, "statement.MyElement is null");

            Node revenue = statement.Children[0] as Node;
            Assert.IsNotNull( revenue, "revenue is null" );
            Assert.AreEqual( "Revenue", revenue.Label, "revenue wrong name" );
            Assert.AreEqual( 5, revenue.Children.Count, "assets has wrong number of children" );

            Node salesRevenueAbs = revenue.Children[0] as Node;
            Assert.IsNotNull( salesRevenueAbs, "salesRevenueAbs is null" );
            Assert.AreEqual( "Sales Revenue", salesRevenueAbs.Label, "revenue wrong name" );
            Assert.AreEqual( 4, salesRevenueAbs.Children.Count, "salesRevenueAbs has wrong number of children" );

            //			Node netSalesProhibited = salesRevenueAbs.Children[2] as Node;
            //			Assert.IsNotNull( netSalesProhibited, "netSalesProhibited is null" );
            //			Assert.IsTrue( netSalesProhibited.IsProhibited, "netSalesProhibited is not prohibited" );

            Node netSales = salesRevenueAbs.Children[2] as Node;
            Assert.IsNotNull( netSales, "netSales is null" );
            Assert.IsFalse( netSales.IsProhibited, "netSales is prohibited" );

            Node operationExpensesAbstract = statement.Children[3] as Node;
            Assert.IsNotNull( operationExpensesAbstract, "operationExpensesAbstract is null" );
            Assert.AreEqual( "Operating Expenses", operationExpensesAbstract.Label, "operationExpensesAbstract wrong name" );
            Assert.AreEqual(12, operationExpensesAbstract.Children.Count, "operationExpensesAbstract has wrong number of children" );

            Node rdExpenseAbs = operationExpensesAbstract.Children[0] as Node;
            Assert.IsNotNull( rdExpenseAbs, "rdExpenseAbs is null" );
            Assert.AreEqual( "Research and Development Expense", rdExpenseAbs.Label, "rdExpenseAbs wrong name" );

            //old dragon tag bug.. we have the same element displaying twice one for order 3 and one for order 3.005
            Assert.AreEqual(6, rdExpenseAbs.Children.Count, "rdExpenseAbs has wrong number of children" );

            Node rdExpenseEx = rdExpenseAbs .Children[0] as Node;
            Assert.IsNotNull( rdExpenseEx, "rdExpenseEx is null" );
            Assert.AreEqual( "Research and Development Expense (Excluding In - Process)", rdExpenseEx.Label, "rdExpenseEx wrong name" );

            Node rdExpenseDev = rdExpenseAbs.Children[1] as Node;
            Assert.IsNotNull( rdExpenseDev, "rdExpenseDev is null" );
            Assert.AreEqual( "In - Process Research and Development", rdExpenseDev.Label, "rdExpenseDev wrong name" );

            Node rdExpenseInc = rdExpenseAbs.Children[5] as Node;
            Assert.IsNotNull( rdExpenseInc, "rdExpenseInc is null" );
            Assert.AreEqual( "Research and development expenses", rdExpenseInc.Label, "rdExpenseInc wrong name" );
            Assert.IsFalse( rdExpenseInc.IsProhibited, "rdExpenseInc is prohibited" );

            //			Node rdExpenseInc2 = rdExpenseAbs.Children[3] as Node;
            //			Assert.IsNotNull( rdExpenseInc2, "rdExpenseInc2 is null" );
            //			Assert.AreEqual( "Research and development expenses", rdExpenseInc2.Label, "rdExpenseInc2 wrong name" );
            //			Assert.IsTrue( rdExpenseInc2.IsProhibited, "rdExpenseInc2 is not prohibited" );

            foreach (Element ele in s.allElements.Values)
            {
                TaxonomyItem ti = s.TaxonomyItems[ele.TaxonomyInfoId];
                Assert.IsNotNull(ti, "taxonomy item does not exist");

                if (!ele.Id.StartsWith(ti.Namespace))
                {
                    Assert.Fail("Failed to set the correct Taxonomy item id for element ");
                }
            }
        }