public void Write_Then_Read_GetDirectory() { // Arrange var getDirectory = new GetDirectory { Meta = { MerchantId = 1, IpAddress = "123.123.123.123", Version = "1.0" }, General = { PaymentProductId = 1, CountryCode = "NL", CurrencyCode = "EUR" } }; // Act var text = ConvertApiDataPartToString(getDirectory); var getDirectory2 = new GetDirectory(); getDirectory2.FromModifiedXml(new ModifiedXmlDocument(text), string.Empty); // Assert Assert.AreEqual(1, getDirectory2.Meta.MerchantId); Assert.AreEqual("123.123.123.123", getDirectory2.Meta.IpAddress); Assert.AreEqual("1.0", getDirectory2.Meta.Version); Assert.AreEqual(1, getDirectory2.General.PaymentProductId); Assert.AreEqual("NL", getDirectory2.General.CountryCode); Assert.AreEqual("EUR", getDirectory2.General.CurrencyCode); }
public static void SetFrameworkSettings() { XPathItem aut; XPathItem userLevel; XPathItem browsertype; XPathItem module; string dir = GetDirectory.GetDir(); string strFileName = dir + "\\AutomationFramework\\Config\\GlobalConfig.xml"; FileStream stream = new FileStream(strFileName, FileMode.Open); XPathDocument document = new XPathDocument(stream); XPathNavigator navigator = document.CreateNavigator(); aut = navigator.SelectSingleNode("/RunSettings/AUT"); browsertype = navigator.SelectSingleNode("/RunSettings/Browser"); userLevel = navigator.SelectSingleNode("/RunSettings/UserLevel"); module = navigator.SelectSingleNode("/RunSettings/Module"); Settings.AUT = aut.Value; Settings.BrowserType = (BrowserType)System.Enum.Parse(typeof(BrowserType), browsertype.Value.ToString()); Settings.UserLevel = userLevel.Value; Settings.Module = module.Value; }
public void TestImportBadges() { int expected = 15; DAO.BadgeDAO badgedao = new DAO.BadgeDAO(); int actual = badgedao.ImportBadges(GetDirectory.getFilePath() + @"\GST_Badge_System.DAO\Data\Staff-Student.csv").Count; Assert.AreEqual(expected, actual); }
public LoginPage() { string path = GetDirectory.GetDir() + "\\HC10Test\\Modules\\LoginPage\\Data\\Credentials.xlsx"; string sheet = Settings.UserLevel; sheet.ToLower(); wb = excel.Workbooks.Open(path); ws = wb.Worksheets[sheet]; }
public void InitializeSettings() { if (DriverContext.Driver == null) { GetDirectory.SetDataDirectory(); ConfigReader.SetFrameworkSettings(); ReporterClass report = new ReporterClass(); report.CreateReporterFile(); OpenBrowser(Settings.BrowserType); DriverContext.Browser.GoToUrl(Settings.AUT); DriverContext.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); DriverContext.Driver.Manage().Window.Maximize(); LoginPage login = new LoginPage(); login.Login(); } }
public SettingsViewModel(IScreen screen, AppSettingsService?settingsService = null) : base(screen, "settings") { this.settingsService = settingsService ?? Locator.Current.GetService <AppSettingsService>(); SavedSettings = this.settingsService.GetSettings(); SelectDirectory = ReactiveCommand.CreateFromObservable(() => GetDirectory.Handle(SoulstormDirectory)); SelectDirectory.Where(dir => dir != null) .ToPropertyEx(this, x => x.SoulstormDirectory, initialValue: SavedSettings.InstallLocation); IObservable <bool> canSave = this.WhenAnyValue(x => x.SoulstormDirectory, x => x.SavedSettings, (dir, settings) => !string.Equals(settings.InstallLocation, dir, StringComparison.OrdinalIgnoreCase)) .DistinctUntilChanged(); SaveSettings = ReactiveCommand.Create(() => { SavedSettings = new AppSettings() { InstallLocation = SoulstormDirectory }; this.settingsService.SaveSettings(SavedSettings); }, canSave); }
public void GetDirectoryTest() { GetDirectory request = new GetDirectory(); var result = JsonConvert.DeserializeObject <KodiJSON.Files.Response.GetDirectoryResponse>(ExecuteTest.GetResponse(request)); }
private void Execute(ISender client, GetDirectory message) { bool isError = false; string statusMessage = null; Action <string> onError = (msg) => { isError = true; statusMessage = msg; }; try { DirectoryInfo dicInfo = new DirectoryInfo(message.RemotePath); FileInfo[] files = dicInfo.GetFiles(); DirectoryInfo[] directories = dicInfo.GetDirectories(); FileSystemEntry[] items = new FileSystemEntry[files.Length + directories.Length]; int offset = 0; for (int i = 0; i < directories.Length; i++, offset++) { items[i] = new FileSystemEntry { EntryType = FileType.Directory, Name = directories[i].Name, Size = 0, LastAccessTimeUtc = directories[i].LastAccessTimeUtc }; } for (int i = 0; i < files.Length; i++) { items[i + offset] = new FileSystemEntry { EntryType = FileType.File, Name = files[i].Name, Size = files[i].Length, ContentType = Path.GetExtension(files[i].Name).ToContentType(), LastAccessTimeUtc = files[i].LastAccessTimeUtc }; } client.Send(new GetDirectoryResponse { RemotePath = message.RemotePath, Items = items }); } catch (UnauthorizedAccessException) { onError("GetDirectory No permission"); } catch (SecurityException) { onError("GetDirectory No permission"); } catch (PathTooLongException) { onError("GetDirectory Path too long"); } catch (DirectoryNotFoundException) { onError("GetDirectory Directory not found"); } catch (FileNotFoundException) { onError("GetDirectory File not found"); } catch (IOException) { onError("GetDirectory I/O error"); } catch (Exception) { onError("GetDirectory Failed"); } finally { if (isError && !string.IsNullOrEmpty(statusMessage)) { client.Send(new SetStatusFileManager { Message = statusMessage, SetLastDirectorySeen = true }); } } }
public static void getDirectory(GetDirectory command, ClientMosaique client) { bool isError = false; string message = null; Action <string> onError = (msg) => { isError = true; message = msg; }; try { DirectoryInfo dicInfo = new DirectoryInfo(command.remotePath); FileInfo[] iFiles = dicInfo.GetFiles(); DirectoryInfo[] iFolders = dicInfo.GetDirectories(); string[] files = new string[iFiles.Length]; long[] filessize = new long[iFiles.Length]; string[] folders = new string[iFolders.Length]; int i = 0; foreach (FileInfo file in iFiles) { files[i] = file.Name; filessize[i] = file.Length; i++; } if (files.Length == 0) { files = new string[] { DELIMITER }; filessize = new long[] { 0 }; } i = 0; foreach (DirectoryInfo folder in iFolders) { folders[i] = folder.Name; i++; } if (folders.Length == 0) { folders = new string[] { DELIMITER }; } new GetDirectoryResponse(files, folders, filessize).Execute(client); } catch (UnauthorizedAccessException) { onError("GetDirectory No Permission"); } catch (SecurityException) { onError("GetDirectory No permission"); } catch (PathTooLongException) { onError("GetDirectory Path too long"); } catch (DirectoryNotFoundException) { onError("GetDirectory Directory not found"); } catch (FileNotFoundException) { onError("GetDirectory File not found"); } catch (IOException) { onError("GetDirectory I/O error"); } catch (Exception) { onError("GetDirectory Failed"); } finally { if (isError && !string.IsNullOrEmpty(message)) { new SetStatusFileManager(message, true).Execute(client); } } }
private static void handle_directories(GetDirectory cmd) { string path = cmd.dir; List <string> names = new List <string>(); List <string> types = new List <string>(); List <int> sizes = new List <int>(); if (path == "0") { foreach (var drive in DriveInfo.GetDrives()) { names.Add(drive.Name); types.Add("drive"); sizes.Add(0); } names.Add(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); types.Add("Desktop"); sizes.Add(0); names.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); types.Add("MyDocuments"); sizes.Add(0); names.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)); types.Add("MyMusic"); sizes.Add(0); names.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)); types.Add("MyPictures"); sizes.Add(0); names.Add(Environment.GetFolderPath(Environment.SpecialFolder.Startup)); types.Add("Startup"); sizes.Add(0); send_byte(resTObyte(new SendDirectory(names, types, sizes))); return; } else { if (!Directory.Exists(path)) { return; } string [] subdirectoryEntries = Directory.GetDirectories(path); foreach (string subdirectory in subdirectoryEntries) { names.Add(subdirectory); types.Add("folder"); sizes.Add(0); } FileInfo[] fileEntries = new DirectoryInfo(path).GetFiles(); foreach (FileInfo file in fileEntries) { names.Add(file.Name); types.Add(file.Name.Split('.')[file.Name.Split('.').Length - 1]); sizes.Add((int)file.Length); } send_byte(resTObyte(new SendDirectory(names, types, sizes))); } }