//save button clicked private void btnSave_Click(object sender, RoutedEventArgs e) { try { var bankID = BankID.Create(Convert.ToInt32(txID.Text)); //read id from txID var bankName = BankName.Create(txName.Text); //read name from txName var bankURI = BankURI.Create(txURI.Text); //read URI from txURI var bankPattern = BankPattern.Create(txPattern.Text); //read pattern from txPattern var bankBuyIndex = BankIndex.Create(Convert.ToInt32(txBuyIndex.Text)); //read BuyIndex from txBuyIndex var bankSellIndex = BankIndex.Create(Convert.ToInt32(txSellIndex.Text)); //read SellIndex from txSellIndex if (oper == Operations.Edit) //if window in "edit mode" { MainWindow.exchangeRate.RemoveBankInfo(this.bankInfo.ID); //remove bankinfo from list FileHelper.DeleteFromFile(this.bankInfo); //remove bankinfo from file } var bankInfo = CreateBankInfo(bankID, bankName, bankURI, bankPattern, bankBuyIndex, bankSellIndex); MainWindow.exchangeRate.AddBankInfo(bankInfo); //save bankinfo in list FileHelper.WriteInFile(bankInfo); //save bankinfo in file this.DialogResult = true; this.Close(); //close file } catch (Exception excep) { MessageBox.Show(excep.Message); } }
public void CreateBankPattern_Normal() { var expected = @"<td class=""val"">(\d+\.\d+)</td>"; var actual = BankPattern.Create(expected); Assert.AreEqual(expected, actual); }
public void ConvertBankPattern_ToString() { var expceted = @"<td class=""val"">(\d+\.\d+)</td>"; var actual = BankPattern.Create(@"<td class=""val"">(\d+\.\d+)</td>"); Assert.AreEqual(expceted, actual); }
public static void InitializeClass(TestContext testContext) { BankID bankID = BankID.Create(1); BankName bankName = BankName.Create("Ощадбанк"); BankURI bankURI = BankURI.Create("https://www.oschadbank.ua/ru/private/currency/currency_rates/"); BankPattern pattern = BankPattern.Create(@"<td class=""text-right"">(\d+\.\d+)</td>"); BankIndex buyIndex = BankIndex.Create(1); BankIndex sellIndex = BankIndex.Create(2); exchangeRateItem = new BankInfo(bankID, bankName, bankURI, pattern, buyIndex, sellIndex); //initialize BankInfo item exchangeRate = new ExchangeRate(); //initialize ExchangeRate class }
public static void Initialize(TestContext testContext) { File.Delete("BanksInfo.csv"); //delete file if it exist var bankID = BankID.Create(1); var bankName = BankName.Create("Укргазбанк"); var bankURI = BankURI.Create("https://www.ukrgasbank.com/"); var bankPattern = BankPattern.Create(@"<td class=""val"">(\d+\.\d+)</td>"); var bankBuyIndex = BankIndex.Create(0); var bankSellIndex = BankIndex.Create(1); bankInfo = new BankInfo(bankID, bankName, bankURI, bankPattern, bankBuyIndex, bankSellIndex); bankInfo2 = new BankInfo(BankID.Create(2), bankName, bankURI, bankPattern, bankBuyIndex, bankSellIndex); }
private static BankInfo CreateBankInfo(string lineFromFile) { var items = lineFromFile.Split(','); items = items.Select(x => x.Trim()).ToArray(); //remove spaces in words items = items.Where(x => !String.IsNullOrEmpty(x)).ToArray(); //remove empty items if (items.Length == 6) { BankID bankID = BankID.Create(Convert.ToInt32(items[0])); BankName bankName = BankName.Create(items[1]); BankURI bankURI = BankURI.Create(items[2]); BankPattern bankPattern = BankPattern.Create(items[3]); BankIndex bankBuy = BankIndex.Create(Convert.ToInt32(items[4])); BankIndex bankSell = BankIndex.Create(Convert.ToInt32(items[5])); return(new BankInfo(bankID, bankName, bankURI, bankPattern, bankBuy, bankSell)); } else { throw new Exception("Wrong data in file"); } }
public void CreateBankPattern_Null() { var bankPattern = BankPattern.Create(null); }
public void CreateBankPattern_Empty() { var bankPattern = BankPattern.Create(string.Empty); }