public static string ModType(string WorkingDIR) { foreach (var CheckFile in Directory.EnumerateFiles(WorkingDIR, "*.*", SearchOption.AllDirectories)) { if (CheckFile.Contains(".csv")) { if (CheckFile.Contains(@"abdata\list\characustom")) { return("Clothing"); } if (CheckFile.Contains(@"Map_") && CheckFile.Contains(@"abdata\map")) { return("StudioMap"); } if (CheckFile.Contains(@"abdata\studio\info")) { return("Studio"); } if (CheckFile.Contains(@"abdata\map\list")) { return("GameMap"); } } } return("Unknown"); }
public void Execute() { if (!CheckFile.CurrentFolderIsEqualTo("terraform", currentDirectory)) { Cli.PrintLine("Error: You must be in a Terraform project folder root when executing this command.", ConsoleColor.Red); return; } Cli.PrintLine("Please enter the following information."); varInfo.varName = GetVariableName(); varInfo.varType = GetVariableType(); varInfo.isEnvVar = GetIsEnvVariable(); if (varInfo.isEnvVar) { varInfo.DevValue = GetVariableValue("Dev"); varInfo.QaValue = GetVariableValue("QA"); varInfo.QtsValue = GetVariableValue("QTS"); varInfo.ProdValue = GetVariableValue("Production"); } else { varInfo.GlobalValue = GetVariableValue("Global"); } var varLists = collectData.PopulateVarLists(currentDirectory); var variableControl = new VariableControl(currentDirectory); variableControl.UpsertVariable(varInfo, varLists); }
public void FileCompareDifExt() { string fileOne = CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPARE_ONE].ToString()); string fileTwo = CheckFile.GetPath(TestContext.DataRow[COMPARE_FILE].ToString()); Assert.IsFalse(CheckFile.CompareFile(fileOne, fileTwo), "File Compare Funct"); }
public void FileCompareSameExtAreEqual() { string fileOne = CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPARE_ONE].ToString()); string fileTwo = CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPARE_ONE].ToString()); Assert.IsTrue(CheckFile.CompareFile(@fileOne, @fileTwo), "File Compare Funct"); }
public bool Object_builder(string path_to_file, Signature sgntr, ref string virus_name) { CheckFile chck_file = new CheckFile(path_to_file); ScanObject scanObject = new ScanObject(); if (chck_file.IsFilePE()) { return(scanObject.Block_read(1, path_to_file, sgntr, ref virus_name));// flag = 1; } else { if (chck_file.IsFileZip()) { return(scanObject.Block_read(2, path_to_file, sgntr, ref virus_name)); } else { if (chck_file.IsFileDir()) { Object_builder_for_dir(path_to_file, sgntr, ref virus_name); return(false); } else { return(false); } } } }
public void GetPathTestPass() { string path = "..\\..\\EncryptionTestFiles\\EncryptedPngOne.png"; string retPath = CheckFile.GetPath(path); Assert.AreEqual(Directory.GetParent(path).FullName + path, CheckFile.GetPath(path)); Assert.IsTrue(File.Exists(retPath), " file does not exsist"); }
public void ShouldThrowExceptionWhenNotDateNotFormatted() { //Arrange string inputText = "Startdatum: testing"; // Geen datum CheckFile checkFile = new CheckFile(); //Act & Assert checkFile.ExtractStartDatum(inputText); }
public void ShouldThrowExceptionWhenNotDateButFormatted() { //Arrange string inputText = "Startdatum: 15/13/2018"; // 13e maand CheckFile checkFile = new CheckFile(); //Act & Assert checkFile.ExtractStartDatum(inputText); }
public void NullValueShouldThrowError() { // Arrange string input = null; CheckFile checkFile = new CheckFile(); // Act checkFile.ExtractDuur(input); }
public void TestResourceDifFile() { Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPRESS + ONE_KEYWORD].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPRESS + TWO_KEYWORD].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[COMPRESSED_FILE + ONE_KEYWORD].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[COMPRESSED_FILE + TWO_KEYWORD].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[DECOMPRESSED_FILE + ONE_KEYWORD].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[DECOMPRESSED_FILE + TWO_KEYWORD].ToString()))); }
/// <summary> /// test to make sure that two different files compress differently /// </summary> /// <param name="uncompressedOne">first starting path</param> /// <param name="uncompressedTwo">second starting path</param> /// <param name="compressedOne">first compressed file</param> /// <param name="compressedTwo">second compressed file</param> public void TestDifFileCompression(string uncompressedOne, string uncompressedTwo, string compressedOne, string compressedTwo) { TestFileCompression(uncompressedOne, compressedOne); TestFileCompression(uncompressedTwo, compressedTwo); Assert.IsFalse(CheckFile.CompareFile(uncompressedOne, uncompressedTwo), " Files are not different"); Assert.IsFalse(CheckFile.CompareFile(compressedOne, compressedTwo), " Files did not compress differently"); }
/// <summary> /// 检查事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheck_Click(object sender, EventArgs e) { //检查文件路径 if (cbJGFHX.Checked) { CheckPath checkPath = new CheckPath(); checkPath.CheckPathMsg(tbBrowse.Text, this); } //成果文件配置 if (cbJGFHX.Checked) { CheckFile checkFile = new CheckFile(); checkFile.CheckFileMsg(checkFile.ReturnFiles(tbBrowse.Text, this), tbBrowse.Text, this); } if (cbJCZB.Checked) { CheckFile checkFile = new CheckFile(); CheckZhiBiao zhibiao = new CheckZhiBiao(); //zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this); Thread thread = new Thread(delegate() { zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this); }); thread.Start(); } if (cbJCZB.Checked) { CheckGuiZe guize = new CheckGuiZe(); guize.CheckSempleGuiZe(tbBrowse.Text, this); } /********************此区域预留用于检查其它项目,代码参考CheckPathMsg**************************/ /********************************************************************************************/ //将错误信息写入首页的DataGridView WriteFile writeFile = new WriteFile(); this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入列表文件"; writeFile.WriteDataGridView(ComMsg.ResultShow, this.dgCheckResult); //生成文档 CreateFile createFile = new CreateFile(); createFile.CreateDoc(tbBrowse.Text, cmbType.Text); //创建word文档 createFile.CreateXls(tbBrowse.Text, cmbType.Text); //创建Excel文档 //写入文档 this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Excel文件"; writeFile.WriteXls(ComMsg.xlsPath); //向Excel文档中写入检查结果 this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Word文件"; createFile.WrithDocFile(ComMsg.docPath); //向doc文档中写入检查结果 //清空相关的文档 ComMsg.docPath = string.Empty; ComMsg.xlsPath = string.Empty; ComMsg.infoList = new List <FileInfo>(); ComMsg.ResultShow = new List <ResultEntity>(); }
public void DecompressFileTest() { string fileToCompress = TestContext.DataRow[FILE_TO_COMPRESS].ToString(); string compressedFile = TestContext.DataRow[COMPRESSED_FILE].ToString(); string decompressed = TestContext.DataRow[DECOMPRESSED_FILE].ToString(); tree.Compress(fileToCompress, compressedFile); TestFileCompression(fileToCompress, compressedFile); tree.Decompress(compressedFile, decompressed); TestFileCompression(decompressed, compressedFile); Assert.IsTrue(CheckFile.CompareFile(fileToCompress, decompressed), "Files are not the same"); }
/// <summary> /// test whether two equal files compressed the same /// </summary> /// <param name="uncompressedOne">first starting path</param> /// <param name="uncompressedTwo">second starting path</param> /// <param name="compressedOne">first compressed file</param> /// <param name="compressedTwo">second compressed file</param> public void TestSameFileCompression(string uncompressedOne, string uncompressedTwo, string compressedOne, string compressedTwo) { TestFileCompression(uncompressedOne, compressedOne); TestFileCompression(uncompressedTwo, compressedTwo); Assert.IsTrue(CheckFile.CompareFile(uncompressedOne, uncompressedTwo), "{0} is not identical to {1}", Path.GetFileName(uncompressedOne), Path.GetFileName(uncompressedTwo)); Assert.IsTrue(CheckFile.CompareFile(compressedOne, compressedTwo), "{0} did not compress in the same format as {1}", Path.GetFileName(compressedOne), Path.GetFileName(compressedTwo)); }
public void ValidInputTextExtractsValidCode() { //Arrange string inputText = "Cursuscode: CNETIN"; string expected = "CNETIN"; CheckFile checkFile = new CheckFile(); //Act string actual = checkFile.ExtractCode(inputText); // Assert Assert.IsTrue(string.Equals(actual, expected)); }
public void ValidInputTextExtractsValidTitle() { //Arrange string inputText = "Titel: C# Programmeren"; string expected = " C# Programmeren"; CheckFile checkFile = new CheckFile(); //Act string actual = checkFile.ExtractTitle(inputText); // Assert Assert.IsTrue(string.Equals(actual, expected)); }
public void ValidInputTextExtractsValidCode() { //Arrange string inputText = "Duur: 5 dagen"; int expected = 5; CheckFile checkFile = new CheckFile(); //Act int actual = checkFile.ExtractDuur(inputText); // Assert Assert.IsTrue(actual == expected); }
public void ValidInputTextExtractsValidCode() { //Arrange string inputText = "Startdatum: 15/10/2018"; DateTime expected = new DateTime(2018, 10, 15); CheckFile checkFile = new CheckFile(); //Act DateTime actual = checkFile.ExtractStartDatum(inputText); // Assert Assert.IsTrue(actual == expected); }
public void CheckFile() { var checkFiles = new List <ParserFileInfo>(); foreach (var file in _info) { checkFiles.Add(file); } var scienceFile = checkFiles.Find(q => q.Type == "Эталон Научной"); var funFile = checkFiles.Find(q => q.Type == "Эталон художественного"); var poemFile = checkFiles.Find(q => q.Type == "Эталон стихотворения"); var needCheckFiles = checkFiles.Where(q => q.NeedCheck); foreach (var file in needCheckFiles) { CheckOnCriteria(scienceFile.QuotesText, funFile.QuotesText, poemFile.QuotesText, file.QuotesText, file); CheckOnCriteria(scienceFile.DirectSpeech, funFile.DirectSpeech, poemFile.DirectSpeech, file.DirectSpeech, file); CheckOnCriteria(scienceFile.CommasCount, funFile.CommasCount, poemFile.CommasCount, file.CommasCount, file); CheckOnCriteria(scienceFile.LineBreaksToParagraphCount, funFile.LineBreaksToParagraphCount, poemFile.LineBreaksToParagraphCount, file.LineBreaksToParagraphCount, file); CheckOnCriteria(scienceFile.ForeignWordsCountAverage, funFile.ForeignWordsCountAverage, poemFile.ForeignWordsCountAverage, file.ForeignWordsCountAverage, file); CheckOnCriteria(scienceFile.SentenceWordCount, funFile.SentenceWordCount, poemFile.SentenceWordCount, file.SentenceWordCount, file); CheckOnCriteria(scienceFile.AverageWordLength, funFile.AverageWordLength, poemFile.AverageWordLength, file.AverageWordLength, file); CheckOnCriteria(scienceFile.CorrelationFirstCriteria, funFile.CorrelationFirstCriteria, poemFile.CorrelationFirstCriteria, file.CorrelationFirstCriteria, file); CheckOnCriteria(scienceFile.CorrelationSecondCriteria, funFile.CorrelationSecondCriteria, poemFile.CorrelationSecondCriteria, file.CorrelationSecondCriteria, file); var finalCheck = new CheckFile(); finalCheck.ScienceClass = Math.Round(file.checkData.Sum(q => q.ScienceClass) / file.checkData.Count, 2); finalCheck.FunClass = Math.Round(file.checkData.Sum(q => q.FunClass) / file.checkData.Count, 2); finalCheck.PoemClass = Math.Round(file.checkData.Sum(q => q.PoemClass) / file.checkData.Count, 2); file.FinalCheck = "Науч-" + finalCheck.ScienceClass + "%; Худ-" + finalCheck.FunClass + "%; Стих-" + finalCheck.PoemClass + "%"; if (finalCheck.PoemClass > finalCheck.FunClass && finalCheck.PoemClass > finalCheck.ScienceClass) { file.CheckResult = "Стихотворный класс"; } if (finalCheck.FunClass > finalCheck.PoemClass && finalCheck.FunClass > finalCheck.ScienceClass) { file.CheckResult = "Художественный класс"; } if (finalCheck.ScienceClass > finalCheck.FunClass && finalCheck.ScienceClass > finalCheck.PoemClass) { file.CheckResult = "Научный класс"; } file.NeedCheck = false; } _info.GroupBy(q => q.CheckResult); }
public bool Object_builder(string path_to_file, Signature sgntr, ref string virus_name, ref string path_to_infected_file) { CheckFile chck_file = new CheckFile(path_to_file); if (chck_file.IsFilePE()) { if (scanObject.Block_read(1, path_to_file, sgntr, ref virus_name, ref path_to_infected_file)) { infected_files.Add(path_to_infected_file, virus_name); return(true); } else { scn_report.Add_record(false, not_a_virus, not_a_virus); return(false);// flag = 1; } } else { if (chck_file.IsFileZip()) { if (scanObject.Block_read(2, path_to_file, sgntr, ref virus_name, ref path_to_infected_file)) { infected_files.Add(path_to_infected_file, virus_name); return(true); } else { scn_report.Add_record(false, not_a_virus, not_a_virus); return(false); } } else { if (chck_file.IsFileDir()) { Object_builder_for_dir(path_to_file, sgntr, ref virus_name, ref path_to_infected_file); return(false); } else { scn_report.Add_record(false, not_a_virus, not_a_virus); return(false); } } } }
private static void CheckOnCriteria(double scienceFile, double funFile, double poemFile, double file, ParserFileInfo fileClass) { var sumCriteria = Math.Abs(scienceFile - file) + Math.Abs(funFile - file) + Math.Abs(poemFile - file); CheckFile data = new CheckFile(); if (sumCriteria == 0) { sumCriteria = 1; } data.ScienceClass = (sumCriteria - Math.Abs(scienceFile - file)) / sumCriteria * 100; data.FunClass = (sumCriteria - Math.Abs(funFile - file)) / sumCriteria * 100; data.PoemClass = (sumCriteria - Math.Abs(poemFile - file)) / sumCriteria * 100; fileClass.checkData.Add(data); }
private async Task CheckParagraph(string paragraph) { CheckFile cf = new CheckFile(); string[] line = paragraph.Split("\n"); //check of Cursus al bestaat if (!_context.cursussen.Any(e => e.CursusCode.Equals(cf.ExtractCode(line[1])))) { Cursus cursus = new Cursus(cf.ExtractTitle(line[0]), cf.ExtractCode(line[1]), cf.ExtractDuur(line[2])); await addCursus(cursus); } else { int id = _context.cursussen.SingleOrDefault(c => c.CursusCode == cf.ExtractCode(line[1])).Id; DateTime startDatum = cf.ExtractStartDatum(line[3]); Cursusinstantie cursusinstantie = new Cursusinstantie(id, startDatum); await addCursusInstantie(cursusinstantie); } }
public void DecompressFileDifFileTest() { string fileToCompressOne = TestContext.DataRow[FILE_TO_COMPRESS + ONE_KEYWORD].ToString(); string fileToCompressTwo = TestContext.DataRow[FILE_TO_COMPRESS + TWO_KEYWORD].ToString(); string compressedFileOne = TestContext.DataRow[COMPRESSED_FILE + ONE_KEYWORD].ToString(); string compressedFileTwo = TestContext.DataRow[COMPRESSED_FILE + TWO_KEYWORD].ToString(); string decompressedOne = TestContext.DataRow[DECOMPRESSED_FILE + ONE_KEYWORD].ToString(); string decompressedTwo = TestContext.DataRow[DECOMPRESSED_FILE + TWO_KEYWORD].ToString(); Task CmprsOne = Task.Run(() => tree.Compress(fileToCompressOne, compressedFileOne)); Task ComprsTwo = Task.Run(() => tree.Compress(fileToCompressTwo, compressedFileTwo)); Task.WaitAll(CmprsOne, ComprsTwo); TestDifFileCompression(fileToCompressOne, fileToCompressTwo, compressedFileOne, compressedFileTwo); Task DcmprsOne = Task.Run(() => tree.Decompress(compressedFileOne, decompressedOne)); Task DcmprsTwo = Task.Run(() => tree.Decompress(compressedFileTwo, decompressedTwo)); Task.WaitAll(DcmprsOne, DcmprsTwo); TestDifFileCompression(decompressedOne, decompressedTwo, compressedFileOne, compressedFileTwo); Assert.IsTrue(CheckFile.CompareFile(fileToCompressOne, decompressedOne), "Files are not the same"); Assert.IsTrue(CheckFile.CompareFile(fileToCompressTwo, decompressedTwo), "Files are not the same"); }
private async void BtnCheck_Click(object sender, EventArgs e) { try { this.SetCheckFileButtonStatus(false); StartNewTask(); CheckFileParameter param = GetCheckFileParameter(); CheckFile checkhreading = new CheckFile(this.log, this.tokenSource, param); task = checkhreading.Run(); await task; // } catch (Exception ex) { log.RecordError(ex.Message); //this.SetFolderButtonStatus(true); } finally { this.SetCheckFileButtonStatus(true); } }
public static bool CABOverride(string WorkingDIR) { foreach (var CheckFile in Directory.EnumerateFiles(WorkingDIR, "*.*", SearchOption.AllDirectories)) { if (CheckFile.Contains(".csv")) { if (CheckFile.Contains(@"abdata\map\list\mapinfo")) // HS2 Map { return(true); } if (CheckFile.Contains(@"abdata\studio\info\kPlug")) // Studio map { return(true); } if (CheckFile.Contains(@"data_prefab_")) // Hooh modding tool { return(true); } } } return(false); }
public void TestResourceOneFile() { Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[FILE_TO_COMPRESS].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[COMPRESSED_FILE].ToString()))); Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[DECOMPRESSED_FILE].ToString()))); }
/// <summary> /// Tests to see Compression occured /// </summary> /// <param name="fileToCompress">intial state of the file</param> /// <param name="compressedFile">compressed file</param> public void TestFileCompression(string fileToCompress, string compressedFile) { Assert.IsFalse(CheckFile.CompareFile(fileToCompress, compressedFile), "Did not compress Correctly"); }
public void testResourceLocations() { Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow[RESOURCE_FILE].ToString()))); Assert.AreNotEqual("", TestContext.DataRow["type"].ToString()); }
private int __gen_problems = 0; // Keeps track of the # of // general data problems /// <summary> /// Constructor that initializes the component type and CheckFile. /// The check file can contain data checks from several components. /// Each time this class is called to check a component the same /// check file should be sent if the data is to be appended to /// that check file. The CheckFile object is passed around the /// data checks and data that fails the checks are added to it. </summary> /// <param name="comp"> StateMod component type. </param> /// <param name="file"> CheckFile to append data checks to. </param> public StateMod_ComponentDataCheck(int type, CheckFile file, StateMod_DataSet set) : base(type, file) { __check_file = file; __type = type; __dataset = set; }
public void TestResourceLocations() { Assert.IsTrue(File.Exists(CheckFile.GetPath(TestContext.DataRow["file"].ToString()))); }