Ejemplo n.º 1
0
        //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);
            }
        }
Ejemplo n.º 2
0
        public void CreateBankName_EnglishName()
        {
            var expected = "Bank";

            var actual = BankName.Create(expected);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void ConvertBankName_ToString()
        {
            var expected = "Bank";

            var actual = BankName.Create("Bank");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void CreateBankName_RussianName()
        {
            var expected = "Банк";

            var actual = BankName.Create(expected);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void Configure(EntityTypeBuilder <CashAccount> entity)
 {
     entity.ToTable("CashAccounts", schema: "Finance");
     entity.HasKey(e => e.Id);
     entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("CashAccountId");
     entity.HasMany(p => p.CashAccountTransactions).WithOne().HasForeignKey(p => p.CashAccountId);
     entity.Property(p => p.BankName)
     .HasConversion(p => p.Value, p => BankName.Create(p))
     .HasColumnType("NVARCHAR(50)")
     .HasColumnName("BankName")
     .IsRequired();
     entity.Property(p => p.CashAccountName)
     .HasConversion(p => p.Value, p => CashAccountName.Create(p))
     .HasColumnType("NVARCHAR(50)")
     .HasColumnName("AccountName")
     .IsRequired();
     entity.Property(p => p.CashAccountNumber)
     .HasConversion(p => p.Value, p => CashAccountNumber.Create(p))
     .HasColumnType("NVARCHAR(50)")
     .HasColumnName("AccountNumber")
     .IsRequired();
     entity.Property(p => p.RoutingTransitNumber)
     .HasConversion(p => p.Value, p => RoutingTransitNumber.Create(p))
     .HasColumnType("NCHAR(9)")
     .HasColumnName("RoutingTransitNumber")
     .IsRequired();
     entity.Property(p => p.DateOpened)
     .HasConversion(p => p.Value, p => DateOpened.Create(p))
     .HasColumnType("datetime2(0)")
     .HasColumnName("DateOpened")
     .IsRequired();
     entity.Property(p => p.UserId)
     .HasConversion(p => p.Value, p => UserId.Create(p))
     .HasColumnType("UNIQUEIDENTIFIER")
     .HasColumnName("UserId")
     .IsRequired();
     entity.Property(e => e.CreatedDate)
     .HasColumnType("datetime2(7)")
     .ValueGeneratedOnAdd()
     .HasDefaultValueSql("sysdatetime()");
     entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)");
 }
        public async Task ShouldInsert_CashAccount_UsingCashAccountRepo()
        {
            CashAccount account = new CashAccount
                                  (
                CashAccountId.Create(new Guid("1e5b3dcf-9ffd-4671-95ee-373e4ca08804")),
                BankName.Create("ABCDEFG Banking & Hair Stylist, Inc."),
                CashAccountName.Create("Entertainment"),
                CashAccountNumber.Create("12345-678987"),
                RoutingTransitNumber.Create("125478991"),
                DateOpened.Create(new DateTime(2021, 11, 6)),
                UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"))
                                  );

            await _cashAcctRepo.AddAsync(account);

            await _unitOfWork.Commit();

            var result = await _cashAcctRepo.Exists(account.Id);

            Assert.True(result);
        }
        public async Task ShouldUpdate_CashAccount_UsingCashAccountRepo()
        {
            CashAccount account = await _cashAcctRepo.GetByIdAsync(new Guid("765ec2b0-406a-4e42-b831-c9aa63800e76"));

            account.UpdateBankName(BankName.Create("Test Bank"));
            account.UpdateCashAccountName(CashAccountName.Create("Testing Account"));
            account.UpdateCashAccountNumber(CashAccountNumber.Create("9876543210"));
            account.UpdateRoutingTransitNumber(RoutingTransitNumber.Create("125478991"));
            account.UpdateDateOpened(DateOpened.Create(new DateTime(2021, 11, 7)));
            account.UpdateUserId(UserId.Create(UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"))));

            await _unitOfWork.Commit();

            CashAccount result = await _cashAcctRepo.GetByIdAsync(new Guid("765ec2b0-406a-4e42-b831-c9aa63800e76"));

            Assert.Equal("Test Bank", result.BankName);
            Assert.Equal("Testing Account", result.CashAccountName);
            Assert.Equal("9876543210", result.CashAccountNumber);
            Assert.Equal("125478991", result.RoutingTransitNumber);
            Assert.Equal(new DateTime(2021, 11, 7), result.DateOpened);
            Assert.Equal(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"), result.UserId);
        }
Ejemplo n.º 10
0
        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");
            }
        }
Ejemplo n.º 11
0
 public void CreateBankName_SpecialSymbols()
 {
     var bankName = BankName.Create("Bank*_");
 }
Ejemplo n.º 12
0
 public void CreateBankName_WithDigits()
 {
     var bankName = BankName.Create("12Bank2");
 }
Ejemplo n.º 13
0
 public void CreateBankName_Null()
 {
     var bankName = BankName.Create(null);
 }
Ejemplo n.º 14
0
 public void CreateBankName_Empty()
 {
     var bankName = BankName.Create("");
 }