Example #1
0
        public void Deduct_balance_by_withdrawn_amount()
        {
            var accountRepo = A.Fake<IAccountRepository>();
            var transactionRepo = A.Fake<ITransactionRepository>();

            //افترض وجود حساب لعميل
            int accountId = 1;
            decimal amount = 500;
            var account = new Account(){Balance=1000};
            A.CallTo(() =>
                accountRepo.Get(1))
                .Returns(account);
            //عندما اعطي رقم الحساب و القيمة
            //ثم اقوم بعملية السحب
            //Execution
            var sut = new AccountantService(accountRepo, transactionRepo);
            var result = sut.Withdraw(accountId,amount);
            A.CallTo(() => accountRepo.Get(1)).MustHaveHappened(Repeated.AtLeast.Once);

            //يقوم النظام بتعديل رصيد الحساب في قاعدة البيانات
            A.CallTo(()=>accountRepo.Update(account)).MustHaveHappened(Repeated.AtLeast.Once);

            //اجد الرصيد نقص بمقدار هذه القيمة
            Assert.AreEqual(500,result.Balance);
        }
Example #2
0
        public void Create_transaction_to_register_withdrawal_action()
        {
            var accountRepo = A.Fake<IAccountRepository>();
            var transactionRepo = A.Fake<ITransactionRepository>();
            //افترض وجود حساب لعميل
            int accountId = 1;
            decimal amount = 500;

            //عندما اعطي رقم الحساب و القيمة
            //ثم اقوم بعملية السحب
            //Execution
            var sut = new AccountantService(accountRepo,transactionRepo);
            var result = sut.Withdraw(accountId,amount);
            //ويقوم النظام بتسجيل حركة حساب بعملية السحب التي تمت
            A.CallTo(() => transactionRepo.Create(accountId,amount)).MustHaveHappened(Repeated.Exactly.Once);
        }
Example #3
0
        public void Should_Update_AccountBalance_After_Deposit()
        {
            //تجهيز
            var accRepoFake = A.Fake<IAccountsRepository>();
            var account = new Account();
            A.CallTo(() =>
                accRepoFake.Get(1))
                .Returns(account);

            var transRepoFake = A.Fake<ITransactionsRepository>();
            var sut = new AccountantService(accRepoFake,transRepoFake);
            //تنفيذ
            var result = sut.Deposit(1, 1000);
            //تحقق
            A.CallTo(() =>
               accRepoFake.Update(account)).MustHaveHappened(Repeated.Exactly.Once);
        }
Example #4
0
        public void Should_Increase_AccountBalance_After_Deposit()
        {
            //تجهيز
            var accRepoFake = A.Fake<IAccountsRepository>();
            A.CallTo(() => accRepoFake.Get(1)).Returns(
                new Account()
                {
                    Balance = 500
                });

            var transRepoFake = A.Fake<ITransactionsRepository>();
            var sut = new AccountantService(accRepoFake,transRepoFake);
            //تنفيذ
            var result = sut.Deposit(1, 1000);
            //تحقق
            Assert.That(result.Balance,Is.EqualTo(1500));
        }
        /// <summary>
        /// get report from accountant service and data bind them to UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DropDownDistrict_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //instantiate a new instance of accountant service
                IAccountantService accountantService = new AccountantService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId());

                //get report for district selected by user
                var report = accountantService.printMonthlyCostByDistrict(new Guid(DropDownDistrict.SelectedValue)).ToList();
                ReportListView.DataSource = report;
                ReportListView.DataBind();
            }
            catch (Exception)
            {
                Response.Redirect("~/Errors/InternalErrors.aspx", true);
            }
        }
 public AccountantPresenter(IAccountantView view)
     : base(view)
 {
     service = new AccountantService();
 }
 public AccountantController(SportObjectsReservationContext context, AccountantService service)
 {
     _context = context;
     _service = service;
 }