public void TestGetARowData() { var uatRowId = 2; Assert.IsTrue(File.Exists(Path.Combine(_filePath, FileName))); // copy file _destFolder = Path.Combine( FileAndFolder.GetExecutionDirectory(), SolutionFolders.Resources.ToString(), SolutionFolders.Resources.ToString(), "HomePageLocator" ); if (!Directory.Exists(_destFolder)) { Directory.CreateDirectory(_destFolder); } FileAndFolder.CopyFile(FileName, _filePath, FileName, _destFolder); _destFile = Path.Combine(_destFolder, FileName); Assert.IsTrue(File.Exists(_destFile)); var row = _excel.GetRow(_destFile, uatRowId); Console.WriteLine(row); Assert.NotNull(row, "Row Should not be null"); Assert.IsTrue(row.Count == 3, "Expecting 3 Columns in the row id: " + uatRowId); }
public void GetRowByRowData() { Assert.IsTrue(File.Exists(Path.Combine(_filePath, FileName))); // copy file _destFolder = Path.Combine( FileAndFolder.GetExecutionDirectory(), SolutionFolders.Resources.ToString(), SolutionFolders.Resources.ToString(), "HomePageLocator" ); if (!Directory.Exists(_destFolder)) { Directory.CreateDirectory(_destFolder); } FileAndFolder.CopyFile(FileName, _filePath, FileName, _destFolder); _destFile = Path.Combine(_destFolder, FileName); Assert.IsTrue(File.Exists(_destFile)); var allObjects = _excel.GetExcelFileObjects(_destFile); var rows = allObjects.GetLength(0); //var columns = allObjects.GetLength(1); for (var r = 1; r < rows; r++) { var pageObject = new PageElement { Name = allObjects.GetValue(r, 0).ToString(), By = allObjects.GetValue(r, 1).ToString(), Query = allObjects.GetValue(r, 2).ToString(), }; Console.WriteLine(pageObject); Assert.NotNull(pageObject); } }
public void CanGetPageElementCollection() { //Setup var destFolderName = "PageObject"; var destFolder = Path.Combine( FileAndFolder.GetExecutionDirectory(), SolutionFolders.Resources.ToString(), SolutionFolders.Resources.ToString(), destFolderName ); if (!Directory.Exists(destFolder)) { Directory.CreateDirectory(destFolder); } var exePath = FileAndFolder.GetProjectPath(); var filePath = Path.Combine(exePath, "DevTests", SolutionFolders.Resources.ToString()); FileAndFolder.CopyFile(FileName, filePath, FileName, destFolder); // instanciate var pageElement = new PageElement(); var folderStructure = new string[] { SolutionFolders.Resources.ToString(), SolutionFolders.Resources.ToString(), destFolderName }; var pageElementCollection = pageElement.GetPageElementsFromExccelFile(FileName, folderStructure); // Assert Assert.IsTrue(pageElementCollection.Count == 3); // Tear Down File.Delete(Path.Combine(destFolder, FileName)); Directory.Delete(destFolder); }
public void GlobalTeardown() { var exeDir = FileAndFolder.GetExecutionDirectory(); var allureReport = Path.GetFullPath(Path.Combine(exeDir, "..\\..\\")); allureReport = Path.Combine(allureReport, SolutionFolders.Reports.ToString()); var filename = "TestResult.xml"; var allureReportFullPath = Path.Combine(allureReport, filename); Assert.True(File.Exists(allureReportFullPath)); var configurationReader = new ConfigurationReader(); var uat = configurationReader.ReadFolderPathFromConfigurationFile(SolutionFolders.Reports); FileAndFolder.CopyFile(filename, allureReport, filename, uat); Assert.IsTrue(File.Exists(Path.Combine(uat, filename))); }
public void GlobalSetup() { XmlConfigurator.Configure(); var dir = AppContext.BaseDirectory; var allureConfigJson = Path.GetFullPath(Path.Combine(dir, "..\\..\\")); var allureConfigJsonFullPath = Path.Combine(allureConfigJson, AllureConfigurationFileName); if (!File.Exists(Path.Combine(dir, AllureConfigurationFileName))) { FileAndFolder.CopyFile(AllureConfigurationFileName, allureConfigJsonFullPath, AllureConfigurationFileName, dir); } Environment.SetEnvironmentVariable( AllureConstants.ALLURE_CONFIG_ENV_VARIABLE, Path.Combine(dir, AllureConstants.CONFIG_FILENAME)); Log.Info($"ALLURE_CONFIG_ENV_VARIABLE Environment Variable Set to: {dir}"); var config = AllureLifecycle.Instance.JsonConfiguration; Log.Info(config); }
public void TestCanCopyFiles() { var uat = FileAndFolder.GetExecutionDirectory(); var filename = "Test.txt"; var path = Path.Combine(uat, filename); try { Assert.IsFalse(File.Exists(path)); var newPath = Path.Combine(uat, SolutionFolders.Reports.ToString()); Assert.IsFalse(File.Exists(Path.Combine(newPath, filename))); using (var fs = File.Create(path)) { var info = new UTF8Encoding(true).GetBytes("This is some text in the file."); // Add some information to the file. fs.Write(info, 0, info.Length); } FileAndFolder.CopyFile(filename, uat, filename, newPath); Console.WriteLine("Solution Dir: " + uat); Assert.IsTrue(File.Exists(Path.Combine(newPath, filename))); File.Delete(path); newPath = Path.Combine(newPath, filename); File.SetAttributes(newPath, FileAttributes.Normal); File.Delete(newPath); Assert.IsFalse(File.Exists(path)); Assert.IsFalse(File.Exists(newPath)); } finally { if (File.Exists(path)) { File.Delete(path); } } }