Exemple #1
0
        public void MakeDepositTransaction_ShouldGiveMoneyToAccount()
        {
            DateTime date = DateTime.UtcNow;
            var      data = new List <UserAccount>()
            {
                new UserAccount(1, "Georgi Georgiev", "11/06/2000", "0878444484", "bul Bulgaria 4", "Smolyan", "Smolyan", "Male", "married",
                                null, null, 7500, date.ToString()),
                new UserAccount(2, "Ivan Ivanov", "22/11/2001", "0878171711", "bul Bulgaria 3", "Smolyan", "Smolyan", "Male", "married",
                                null, null, 5000, date.ToString())
            }.AsQueryable();
            var mockSet = new Mock <DbSet <UserAccount> >();

            mockSet.As <IQueryable <UserAccount> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <UserAccount> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <UserAccount> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <UserAccount> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            var mockContext = new Mock <banking_dbContext>();

            mockContext.Setup(c => c.UserAccount).Returns(mockSet.Object);
            var service = new UserAccountController(mockContext.Object);

            data.ToList().ForEach(a => service.Add(a));
            service.MakeDepositTransaction(100, data.First());
            Assert.AreEqual(7600, data.First().Balance);
        }
Exemple #2
0
        //Run when "Update" button is clicked. Get information for the detalis of UserAccount and update them with specified data
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Deposit deposit = new Deposit();

            {
                deposit.Date       = lblDate.Text;
                deposit.AccountNo  = Convert.ToDecimal(txtAccNum.Text);
                deposit.Name       = txtName.Text;
                deposit.OldBalance = Convert.ToDecimal(txtOldBalance.Text);
                deposit.Mode       = comboBox1.SelectedItem.ToString();
                deposit.DipAmount  = Convert.ToDecimal(txtDepositAmount.Text);
            }
            depositcontroller.Add(deposit);
            decimal accNo       = Convert.ToDecimal(txtAccNum.Text);
            var     accountSend = accController.Get(accNo).FirstOrDefault();

            accController.MakeDepositTransaction(deposit.DipAmount, accountSend);
            MessageBox.Show($"Успешeно депозирахте {deposit.DipAmount.ToString()}лв. по сметката на {deposit.Name}!");
        }