private static List <ChequeVoucherDTO> GetInactiveRequests(ChequeVouchersDB db, DateTime date)
 => db.InactiveRequests.GetAll()
 .Where(_ => _.RequestDate == date)
 .Select(_ => new ChequeVoucherDTO {
     Request = _
 })
 .ToList();
Ejemplo n.º 2
0
        public void SetAsTakenBack()
        {
            var repo = new Mock <IChequeVouchersRepo>();
            var chq  = CreateValidVoucher();
            var sut  = new ChequeVouchersDB {
                PreparedCheques = repo.Object
            };

            sut.SetAs_TakenBack(chq);

            chq.IssuedDate.Should().BeNull();
            chq.IssuedTo.Should().BeNullOrWhiteSpace();
            repo.Verify(_ => _.Update(chq), Times.Once);
        }
Ejemplo n.º 3
0
        public void SetAsIssued()
        {
            var repo = new Mock <IChequeVouchersRepo>();
            var chq  = CreateValidVoucher();
            var date = DateTime.Now;
            var dude = "Mr. Recipient";
            var sut  = new ChequeVouchersDB {
                PreparedCheques = repo.Object
            };

            sut.SetAs_Issued(chq, date, dude);

            chq.IssuedDate.Should().Be(date);
            chq.IssuedTo.Should().Be(dude);
            repo.Verify(_ => _.Update(chq), Times.Once);
        }
Ejemplo n.º 4
0
        public void SetAsPrepared()
        {
            var activs  = new Mock <IFundRequestsRepo>();
            var inactvs = new Mock <IFundRequestsRepo>();
            var cheques = new Mock <IChequeVouchersRepo>();
            var req     = CreateValidRequest();
            var sut     = new ChequeVouchersDB
            {
                ActiveRequests   = activs.Object,
                InactiveRequests = inactvs.Object,
                PreparedCheques  = cheques.Object
            };

            sut.SetAs_Prepared(req, DateTime.Now, 123);

            cheques.Verify(_ => _.Insert(It.IsAny <ChequeVoucherDTO>()), Times.Once);
            inactvs.Verify(_ => _.Insert(It.IsAny <FundRequestDTO>()), Times.Once);
            activs.Verify(_ => _.Delete(req), Times.Once);
        }
Ejemplo n.º 5
0
        public void SetAsCleared()
        {
            var chqDb = new Mock <IChequeVouchersRepo>();
            var pbkDb = new Mock <IPassbookDB>();
            var pRepo = new Mock <IPassbookRowsRepo>();
            var chq   = CreateValidVoucher();
            var date  = DateTime.Now;
            var sut   = new ChequeVouchersDB
            {
                PreparedCheques = chqDb.Object,
                PassbookRows    = pbkDb.Object
            };

            pbkDb.Setup(_ => _.GetRepo(It.IsAny <int>()))
            .Returns(pRepo.Object);

            sut.SetAs_Cleared(chq, date);

            pRepo.Verify(_ => _.InsertClearedCheque(chq, date), Times.Once);
            pRepo.Verify(_ => _.RecomputeBalancesFrom(date), Times.Once);
            chqDb.Verify(_ => _.Delete(chq), Times.Once);
        }
 private static List <ChequeVoucherDTO> GetPreparedCheques(ChequeVouchersDB db, DateTime date)
 => db.PreparedCheques.GetAll()
 .Where(_ => _.Request.RequestDate == date)
 .ToList();
 private static List <FundRequestDTO> GetActiveRequests(ChequeVouchersDB db, DateTime date)
 => db.ActiveRequests.GetAll()
 .Where(_ => _.RequestDate == date)
 .ToList();