public void TakeInputFolder([FromBody] string zipFilePath) { string name = Path.GetFileNameWithoutExtension(zipFilePath); string extractPath = "..\\Inputs\\" + name; string fxcop = ""; if (Directory.Exists(extractPath)) { Directory.Delete(extractPath, true); } ZipFile.ExtractToDirectory(zipFilePath, extractPath); ToolManager toolManager = new ToolManager(); List <string> input = new List <string>(); string stylecop = extractPath + "\\" + name + "\\*.cs"; fxcop = extractPath + "\\" + name + "\\bin\\Debug\\" + name + ".exe"; if (!(System.IO.File.Exists(fxcop))) { fxcop = extractPath + "\\" + name + "\\bin\\Debug\\" + name + ".dll"; if (!(System.IO.File.Exists(fxcop))) { throw new FileNotFoundException(); } } input.Add(stylecop); input.Add(fxcop); toolManager.StartSession(input); Thread.Sleep(10000); toolManager.ParseXMlFiles(); toolManager.EndSession(); }
public void DownloadFiles(string zipFilePath) { ToolManager toolManager = new ToolManager(); string name = Path.GetFileNameWithoutExtension(zipFilePath); string extractPath = "..\\Inputs\\" + name; if (Directory.Exists(extractPath)) { Directory.Delete(extractPath, true); } ZipFile.ExtractToDirectory(zipFilePath, extractPath); string[] fileDirectory = Directory.GetDirectories(extractPath); string styleCop = ""; string fxCopInputs = ""; string styleCopInputs = ""; List <string> input = new List <string>(); foreach (var dir in fileDirectory) { styleCopInputs = ""; if (CheckForCsFile(dir)) { styleCop = Directory.GetFiles(dir, "*.cs", SearchOption.AllDirectories).First(); } if (CheckForExeFile(dir)) { fxCopInputs = Directory.GetFiles(dir, "*.exe", SearchOption.AllDirectories).First(); } else if (CheckForDllFile(dir)) { fxCopInputs = Directory.GetFiles(dir, "*.dll", SearchOption.AllDirectories).First(); } else { fxCopInputs = ""; } if (styleCop.EndsWith(".cs") && File.Exists(styleCop)) { styleCopInputs = Directory.GetParent(styleCop).ToString() + "\\*.cs"; } if (styleCopInputs != "") { input.Add(styleCopInputs); } if (fxCopInputs != "") { input.Add(fxCopInputs); } } toolManager.StartSession(input); toolManager.ParseXMlFiles(input); toolManager.EndSession(); Thread.Sleep(50000); }
public void When_EndSession_Invoked_Exptected_FileNotFoundException() { ToolManager toolManager = new ToolManager(); toolManager.EndSession(); }