public void TestUsGaap2008_TargetRoleTests2() { //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) ); string fileName = TestCommon.FolderRoot + @"Testing10.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); Assert.AreEqual(0, errors, "should not have any errors"); s.CurrentLanguage = s.SupportedLanguages[0] as string; s.CurrentLabelRole = "preferredLabel"; List<string> selectedURIs = new List<string>(s.roleRefs.Keys); List<Dimension.TargetDimensionInfo> targetExts; Assert.IsFalse(Taxonomy.DoesAnyOfTheSelectedRolesNeedTargetRole(new Taxonomy[] { s }, selectedURIs, out targetExts), "should not have roles that need target role "); List<DimensionNode> titleNodes; s.TryGetAllDimensionNodesForDisplay(s.CurrentLanguage, s.currentLabelRole, true, out titleNodes); int count = 0; foreach( DimensionNode titlenode in titleNodes ) { foreach (DimensionNode hyNode in titlenode.children) { foreach( DimensionNode dimN in hyNode.children ) { foreach (DimensionNode domNode in dimN.children) { if (domNode.Id.Contains("ScenarioUnspecifiedDomain")) { Assert.AreEqual(4, domNode.children.Count, "should have 4 children"); count++; } } } } } Assert.AreEqual(5, count, "should have the dimension in 5 places and should all have 4 children"); }
/// <exclude/> private void TestUsGaap2009Web(string fileName) { //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) ); TestUsGaap2008 s = new TestUsGaap2008(); s.KeepInnerTaxonomies = true; 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"); s.CurrentLanguage = s.SupportedLanguages[0] as string; s.currentLabelRole = PresentationLocator.preferredLabelRole; start = DateTime.Now; s.GetNodesByPresentation(true); s.GetNodesByPresentation(); s.GetNodesByCalculation(); List<DimensionNode> tmp; s.TryGetAllDimensionNodesForDisplay(s.currentLanguage, s.currentLabelRole, true, out tmp); end = DateTime.Now; Console.WriteLine("GET NODES BY PRESENTATION TIME = {0}", end - start); //all the href references should be web based.... foreach (RoleRef rr in s.roleRefs.Values) { Assert.IsTrue(rr.href.StartsWith("http"), "Failed ot build the correct href"); } foreach (RoleType rt in s.roleTypes.Values) { Assert.IsTrue(rt.GetHref().StartsWith("http"), "Failed to build the correct href"); } foreach( TaxonomyItem ti in s.TaxonomyItems ) { Assert.IsTrue(ti.Location.StartsWith("http"), "Failed ot build the correct href"); } 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"); List<string> xsdNames = new List<string>(); foreach (LinkbaseFileInfo lfi in s.linkbaseFileInfos) { foreach (string role in lfi.RoleRefURIs) { Console.WriteLine(" ROLE = {0} XSD = {1}", role , lfi.XSDFileName); } } Dictionary<string, string> linkbaseXSDMap = new Dictionary<string, string>(); foreach (Taxonomy depT in s.DependantTaxonomies) { string xsdName = Path.GetFileName(depT.infos[0].Location); if (depT.presentationFile != null) { foreach (string file in depT.presentationFile) { string val; if (linkbaseXSDMap.TryGetValue(Path.GetFileName(file), out val)) { if (!val.Equals(xsdName)) { Console.WriteLine("FOUND TWO XSD INCLUDING THE SAME PRESENTATION LINKBASE "); Console.WriteLine("{0} {1}", xsdName, val); } } else { linkbaseXSDMap.Add(Path.GetFileName(file), xsdName); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), xsdName); } } if (depT.DefinitionFile != null) { foreach (string file in depT.DefinitionFile) { string val; if (linkbaseXSDMap.TryGetValue(Path.GetFileName(file), out val)) { if (!val.Equals(xsdName)) { Console.WriteLine("FOUND TWO XSD INCLUDING THE SAME DEFINITION LINKBASE "); Console.WriteLine("{0} {1}", xsdName, val); } } else { linkbaseXSDMap.Add(Path.GetFileName(file), xsdName); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), xsdName); } } if (depT.calculationFile != null) { foreach (string file in depT.calculationFile) { string val; if (linkbaseXSDMap.TryGetValue(Path.GetFileName(file), out val)) { if (!val.Equals(xsdName)) { Console.WriteLine("FOUND TWO XSD INCLUDING THE SAME CALCULATION LINKBASE "); Console.WriteLine("{0} {1}", xsdName, val); } } else { linkbaseXSDMap.Add(Path.GetFileName(file), xsdName); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), xsdName); } } if (depT.LabelFile != null) { foreach (string file in depT.LabelFile) { string val; if (linkbaseXSDMap.TryGetValue(Path.GetFileName(file), out val)) { if (!val.Equals(xsdName)) { Console.WriteLine("FOUND TWO XSD INCLUDING THE SAME LABEL LINKBASE "); Console.WriteLine("{0} {1}", xsdName, val); } } else { linkbaseXSDMap.Add(Path.GetFileName(file), xsdName); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), xsdName); } } if (depT.ReferenceFile != null) { foreach (string file in depT.ReferenceFile) { string val; if (linkbaseXSDMap.TryGetValue(Path.GetFileName(file), out val)) { if (!val.Equals(xsdName)) { Console.WriteLine("FOUND TWO XSD INCLUDING THE SAME REFERENCE LINKBASE "); Console.WriteLine("{0} {1}", xsdName, val); } } else { linkbaseXSDMap.Add(Path.GetFileName(file), xsdName); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), xsdName); } } } }