static private void testMove() { Console.WriteLine("=testMove()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); bigList.Move("cache1/"); bigList.Move("cache2/"); bigList.Move("cache3/"); bigList.Move("cache4/"); bigList.Move("C:/cache/"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
public void CanAddAndRemoveNewEntryInListFile() { string newEntry = "UnitTestEntry"; ListFile tempFile = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); {// ADD ENTRY Assert.IsFalse(tempFile.Data.Contains(newEntry)); tempFile.Add(newEntry); Assert.IsTrue(tempFile.Data.Contains(newEntry)); } {// COMMIT ListFile tempFile2 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsFalse(tempFile2.Data.Contains(newEntry)); tempFile.Commit(); Assert.IsTrue(tempFile.Data.Contains(newEntry)); ListFile tempFile3 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile3.Data.Contains(newEntry)); } {// REMOVE ENTRY ListFile tempFile4 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile4.Data.Contains(newEntry)); tempFile4.Remove(newEntry); Assert.IsFalse(tempFile4.Data.Contains(newEntry)); ListFile tempFile5 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile5.Data.Contains(newEntry)); tempFile4.Commit(); ListFile tempFile6 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsFalse(tempFile6.Data.Contains(newEntry)); } }
public ListFile listArquivosCircularByAnoMes(DataTable dt) { ListFile olistFile = new ListFile(); foreach (DataRow dr in dt.Rows) { File oFileModel = new File(); oFileModel.assunto = dr["ASSUNTO"].ToString(); oFileModel.mes = Convert.ToInt32(dr["MES"]); oFileModel.ano = Convert.ToInt32(dr["ANO"]); oFileModel.nameFile = dr["NOME_ARQUIVO"].ToString(); oFileModel.dataPublicacao = Convert.ToDateTime(dr["DATA_GRAVACAO"]); oFileModel.nomeAreaPublicacao = dr["SITE_PUBLICACAO"].ToString(); olistFile.Add(oFileModel); } return(olistFile); }
static private void testPack() { Console.WriteLine("=testArchive()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Pack(); Console.WriteLine("Packed"); bigList.Destroy(); Console.WriteLine("Destroyed"); bigList = new ListFile<List<string>>(0); bigList.Unpack(); Console.WriteLine("Unpacked"); bigList.Load(); Console.WriteLine("Loaded"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
static private void testPath() { Console.WriteLine("=testPath()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0, Path.GetTempPath() + "ListFile Cache\\"); Console.WriteLine(bigList.RootPath); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
static private void testNested3() { Console.WriteLine("=testNestedSerialization()="); Random RNG = new Random(); ListFile<ListFile<ListFile<string>>> outerList = new ListFile<ListFile<ListFile<string>>>(999); for (int z = 0; z < 2; z++) { ListFile<ListFile<string>> bigList = new ListFile<ListFile<string>>(z, "cache/midList" + z + "/"); for (int j = 0; j < 2; j++) { ListFile<string> tempList = new ListFile<string>(j, "cache/innerList" + z + j + "/"); for (int i = 0; i < 2; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } outerList.Add(bigList); } foreach (ListFile<ListFile<string>> bigList in outerList) { foreach (ListFile<string> innerList in bigList) { Console.WriteLine(innerList[0]); innerList.Destroy(); } bigList.Destroy(); } outerList.Destroy(); }
public ListFile listArquivosCircularByAnoMes(DataTable dt) { ListFile olistFile = new ListFile(); foreach (DataRow dr in dt.Rows) { File oFileModel = new File(); oFileModel.assunto = dr["ASSUNTO"].ToString(); oFileModel.mes = Convert.ToInt32(dr["MES"]); oFileModel.ano = Convert.ToInt32(dr["ANO"]); oFileModel.nameFile = dr["NOME_ARQUIVO"].ToString(); oFileModel.dataPublicacao = Convert.ToDateTime(dr["DATA_GRAVACAO"]); oFileModel.nomeAreaPublicacao = dr["SITE_PUBLICACAO"].ToString(); olistFile.Add(oFileModel); } return olistFile; }