public void Export_TestUnsorted() { DatFileUtility.Export(TEST_DATA_UNSORTED_PATH_OUT, TRANSLATIONS, FileType.UnsortedCreditsStringFile); Assert.IsTrue(File.Exists(TEST_DATA_UNSORTED_PATH_OUT)); byte[] b = File.ReadAllBytes(TEST_DATA_UNSORTED_PATH_OUT); UnsortedDatFileBinaryFileBuilder builder = new UnsortedDatFileBinaryFileBuilder(); DatFile datFile = builder.Build(b); Assert.IsNotNull(datFile); Assert.IsTrue(datFile.GetTextItemCount() == TRANSLATIONS.Count); for (int i = 0; i < TRANSLATIONS.Count; i++) { Assert.IsTrue(datFile.GetKeys()[i].CompareTo(new KeyTableRecord(TRANSLATIONS[i].Key)) == 0); Assert.IsTrue(datFile.GetValues()[i].CompareTo(new ValueTableRecord(TRANSLATIONS[i].Value)) == 0); } }
public void Export_TestSorted() { DatFileUtility.Export(TEST_DATA_SORTED_PATH_OUT, TRANSLATIONS); Assert.IsTrue(File.Exists(TEST_DATA_SORTED_PATH_OUT)); byte[] b = File.ReadAllBytes(TEST_DATA_SORTED_PATH_OUT); SortedDatFileBinaryFileBuilder builder = new SortedDatFileBinaryFileBuilder(); DatFile datFile = builder.Build(b); Assert.IsNotNull(datFile); Assert.IsTrue(datFile.GetTextItemCount() == TRANSLATIONS.Count); foreach (Translation translation in TRANSLATIONS) { bool containsKey = datFile.GetKeys().Any(keyTableRecord => keyTableRecord.CompareTo(new KeyTableRecord(translation.Key)) == 0); Assert.IsTrue(containsKey); bool containsValue = datFile.GetValues().Any(valueTableRecord => valueTableRecord.CompareTo(new ValueTableRecord(translation.Value)) == 0); Assert.IsTrue(containsValue); } }