コード例 #1
0
ファイル: TestUsGaap2007.cs プロジェクト: plamikcho/xbrlpoc
        public void TestUsGaap2009_ci_all()
        {
            //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) );
            string fileName = TestCommon.FolderRoot + @"XBRLUS-USGAAP-Taxonomies-2009-01-31\ind\ci" + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-stm-all-2009-01-31.xsd";
            TestUsGaap2008 s = new TestUsGaap2008();

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

            s.Parse(out errors);
            DateTime end = DateTime.Now;
            Console.WriteLine("time taken = {0}", end - start);

            Assert.AreEqual(0, errors, "should not have any errors");
            int countCustomTypeTax = 0;
            foreach (TaxonomyItem ti in s.infos)
            {
                if (ti.HasCustomTypes)
                {
                    countCustomTypeTax++;
                    Console.WriteLine("FOUND CUSTOM TYPES INFO");
                    Console.WriteLine(ti.WebLocation + ti.Location);

                }
            }
            Assert.AreEqual(1, countCustomTypeTax, "Should have only one custom type taxonomy");
            //none of the href references should be web based.
            foreach (RoleRef rr in s.roleRefs.Values)
            {
                Assert.IsFalse(rr.href.StartsWith("http"), "Failed to build the correct href");
                Assert.IsTrue(rr.href.StartsWith(".."), "Failed to build the correct href");
            }

            foreach (RoleType rt in s.roleTypes.Values)
            {
                Assert.IsFalse(rt.GetHref().StartsWith("http"), "Failed to build the correct href");
                Assert.IsTrue(rt.GetHref().StartsWith(".."), "Failed to build the correct href");
            }

            foreach (TaxonomyItem ti in s.TaxonomyItems)
            {
                Assert.IsFalse(ti.Location.StartsWith("http"), "Failed to build the correct href");

            }

            int countRef = 0;
            int countNoRef = 0;

            int noInCal = 0;
            int noNotInCal = 0;
            Hashtable elementTypes = new Hashtable();
            foreach (Element ele in s.allElements.Values)
            {

                Assert.IsTrue(ele.LabelInfo.labelDatas.Count >= 1, "Failed to find label");

                ReferenceLocator rl;
                if (ele.TryGetReferenceLocators(out rl))
                {
                    countRef++;
                }
                else
                {
                    if (!ele.Id.EndsWith("Abstract"))
                    {
                        countNoRef++;
                    }
                }

                if (ele.Id.Equals("us-gaap_AccountsReceivableRelatedPartiesCurrent"))
                {
                    Assert.AreEqual(3, rl.References.Count, "Should have three references");
                }

                if (ele.Id.Equals("us-gaap_AccountsReceivableRelatedPartiesCurrent"))
                {
                    Assert.AreEqual(3, rl.References.Count, "Should have three references");
                }

                if (ele.Id.Equals("us-gaap_AccountsReceivableRelatedParties"))
                {
                    Assert.AreEqual(4, rl.References.Count, "Should have four references");
                }

                if (s.DoesElementExistInCalculation(ele.Id))
                {
                    noInCal++;
                    elementTypes[ele.OrigElementType] = 1;
                }
                else
                {
                    noNotInCal++;
                }

            }

            Console.WriteLine("Count ref = {0} Count no Ref = {1}", countRef, countNoRef);
            Console.WriteLine("Count in calculation = {0} Count not in calculation = {1}", noInCal, noNotInCal);

            foreach (string type in elementTypes.Keys)
            {
                Console.WriteLine("Cal element type = " + type);
            }

            Dictionary<string, string> dt = s.GetSimpleCustomElementTypes();

            foreach (KeyValuePair<string, string> kvp in dt)
            {
                Console.WriteLine("Ext type {0} for base type {1}", kvp.Key, kvp.Value);
            }
        }