Example #1
0
        public InterventionsView()
        {
            InitializeComponent();
            this.CustomizeInterventionsView();

            orderService = new OrderService();
            userService  = new UserService();
            atmService   = new AtmService();


            ///Init Blank report
            ///
            ///
            this.rVReports.LocalReport.DataSources.Clear();
            rVReports.Reset();
            rVReports.LocalReport.ReportPath = "Reports/BlankReport.rdlc";
            var allAtmsDataSource = new AtmService();
            var allAtms           = allAtmsDataSource.GetAllAtmsList();

            Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource();
            rprtDTSource.Name  = "DataSet1";
            rprtDTSource.Value = this.AtmModelBindingSource;
            this.rVReports.LocalReport.DataSources.Add(rprtDTSource);
            this.AtmModelBindingSource.DataSource = allAtms;
            this.rVReports.RefreshReport();
        }
        public void GetNotes_InputNullValue()
        {
            var form = new InputForm()
            {
                ImputedAmount = null, Results = new List <decimal>()
            };
            var atmService = new AtmService();

            Assert.AreEqual(new List <decimal>(), atmService.GetNotes(form));
        }
        public void GetNotes_InputProperValue()
        {
            var form = new InputForm()
            {
                ImputedAmount = 40, Results = new List <decimal>()
            };
            var atmService = new AtmService();

            Assert.AreEqual(new List <decimal>()
            {
                0, 0, 2, 0
            }, atmService.GetNotes(form));
        }
Example #4
0
        public void CheckPin_WithCorrectPinBlock_ReturnsSuccess()
        {
            //setup
            var hsmSrvMock = new Mock <IHsmService>();

            hsmSrvMock.Setup(x => x.CheckPin(It.IsAny <string>())).Returns(PinResult.SuccessfullPin);
            var atmService = new AtmService(hsmSrvMock.Object, null, null);

            //act
            PinResult pr = atmService.CheckPin("32423");

            //assert
            Assert.Equal((int)PinResult.SuccessfullPin, (int)pr);
        }
Example #5
0
        private void BtnAllAtmsReport_Click(object sender, EventArgs e)
        {
            this.rVReports.LocalReport.DataSources.Clear();
            rVReports.Reset();
            rVReports.LocalReport.ReportPath = "Reports/AllAtmsReport.rdlc";
            var allAtmsDataSource = new AtmService();
            var allAtms           = allAtmsDataSource.GetAllAtmsList();

            Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource();
            rprtDTSource.Name  = "DataSet1";
            rprtDTSource.Value = this.AtmModelBindingSource;
            this.rVReports.LocalReport.DataSources.Add(rprtDTSource);
            this.AtmModelBindingSource.DataSource = allAtms;
            this.rVReports.RefreshReport();
        }
Example #6
0
        public void CheckPin_WithWrongPinBlock_ReturnsWrongPin()
        {
            //setup
            string pinBlock = "8778";

            var hsmSrvMock = new Mock <IHsmService>();

            hsmSrvMock.Setup(x => x.CheckPin(pinBlock)).Returns(PinResult.WrongPin);
            var atmService = new AtmService(hsmSrvMock.Object, null, null);

            //act
            PinResult pr = atmService.CheckPin(pinBlock);

            //assert
            Assert.Equal((int)PinResult.ExpiredPin, (int)pr);
        }
Example #7
0
        public void WithdrawalMoney_SubstractAccountBalance()
        {
            //setup
            var dbContext = GetContext();

            var accRepo    = new AccountRepository(dbContext);
            var atmService = new AtmService(null, dbContext, accRepo);

            decimal balanceBefore = accRepo.GetAccount("A123456").Balance;

            //act
            bool result = atmService.WithdrawalMoney(120, "A123456");

            //assert
            decimal afterBalance = accRepo.GetAccount("A123456").Balance;

            Assert.True(result);
            Assert.Equal(balanceBefore - 120, afterBalance);
        }
 public ActionResult Login(AtmLoginModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var credit = AtmService.LoginUser(model.CreditCardNumber, model.PinCode);
             if (credit != null)
             {
                 return(RedirectToAction("WorkPage", new { creditId = credit.Id }));
             }
         }
         catch (Exception)
         {
             ModelState.AddModelError("", "Incorrect account number or pin code.");
             return(View(model));
         }
     }
     return(View(model));
 }
Example #9
0
        public void WithdrawalMoney_SubstractAccountBalance_WithMock()
        {
            //setup
            var accRepoMock = new Mock <IAccountRepository>();

            accRepoMock.Setup(x => x.GetAccount("A123456")).Returns(new Account {
                Balance = 2000
            });

            var atmService = new AtmService(null, null, accRepoMock.Object);

            decimal balanceBefore = accRepoMock.Object.GetAccount("A123456").Balance;

            //act
            bool result = atmService.WithdrawalMoney(120, "A123456");

            //assert
            decimal afterBalance = accRepoMock.Object.GetAccount("A123456").Balance;

            Assert.True(result);
            Assert.Equal(balanceBefore - 120, afterBalance);
            accRepoMock.Verify(mock => mock.Update(It.IsAny <Account>()), Times.Once());
        }
Example #10
0
 public AtmController(AtmService atmService)
 {
     _atmService = atmService;
 }
 public ActionResult TransferMoney(int creditId, string accountNumber, decimal amount)
 {
     AtmService.TransferMoney(creditId, accountNumber, amount);
     return(RedirectToAction("WorkPage", new { creditId = creditId }));
 }
 public ActionResult WithdrawMoney(int creditId, decimal amount)
 {
     AtmService.WithDrawMoney(creditId, amount);
     return(RedirectToAction("WorkPage", new { creditId = creditId }));
 }
Example #13
0
        public void Withdraw_Failure_Insufficient(int amount)
        {
            var atmService = new AtmService();

            Assert.True(atmService.Withdraw(amount));
        }
Example #14
0
        public void Withdraw_Success(int amount)
        {
            var atmService = new AtmService();

            Assert.True(atmService.Withdraw(amount));
        }