public void MakePathForNode() { Taxonomy taxonomy = BaseLuceneIndexMgrTest.ParseTaxonomy(@"xUSGAAP_CI\us-gaap-ci-2005-02-28.xsd"); Node node = ((Node)((Node)taxonomy.GetNodesByPresentation()[0]).Children[0]).Children[0] as Node; string expected = "/Cash Flow from Operations - Direct Method/usfr-pte_NetCashFlowsProvidedUsedOperatingActivitiesDirectAbstract/usfr-pte_CashSaleGoodsServicesAUEND"; Assert.AreEqual(expected, LuceneNodeIndexer.MakePathForNode(node)); }
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"); //} }