Exemplo n.º 1
0
        public void ShouldThrowBillIssuedToItselfIfTwoEndorsementsInARowHasSameBeneficiaryId()
        {
            var endorsements = new List <Endorsement>
            {
                new Endorsement
                {
                    Id = 2, BillId = 1, NewBeneficiaryId = BillBeneficiaryId, PreviousEndorsementId = null
                },
                new Endorsement {
                    Id = 4, BillId = 1, NewBeneficiaryId = BillBeneficiaryId, PreviousEndorsementId = 2
                }
            };

            endorsementRepository.Setup(x => x.Get(int.MaxValue, 0)).Returns(endorsements);
            billOfExchangeRepositoryWithCount.Setup(x => x.GetByIds(new List <int>()
            {
                1
            })).Returns(
                new List <BillOfExchange>()
            {
                new BillOfExchange()
                {
                    BeneficiaryId = 3, DrawerId = 1
                }
            });

            endorsementsService = new EndorsementsService(endorsementRepository.Object, partyRepositoryWithCount.Object,
                                                          billOfExchangeRepositoryWithCount.Object);
            Assert.Throws <BillIssuedToItselfException>(() => endorsementsService.GetEndorsementsForBill(1));
        }
Exemplo n.º 2
0
        public void ShouldThrowCantReferenceOldEndorsementException()
        {
            var endorsements = new List <Endorsement>
            {
                new Endorsement {
                    Id = 2, BillId = 1, NewBeneficiaryId = BillBeneficiaryId, PreviousEndorsementId = 4
                },
                new Endorsement
                {
                    Id = 4, BillId = 1, NewBeneficiaryId = BillBeneficiaryId + 1, PreviousEndorsementId = 2
                }
            };

            endorsementRepository.Setup(x => x.Get(int.MaxValue, 0)).Returns(endorsements);
            partyRepositoryWithCount.Setup(x => x.Get(int.MaxValue, 0)).Returns(new List <Party>()
            {
                ctsTradeItParty
            });
            billOfExchangeRepositoryWithCount.Setup(x => x.GetByIds(new List <int>()
            {
                1
            })).Returns(
                new List <BillOfExchange>()
            {
                new BillOfExchange()
                {
                    BeneficiaryId = 3, DrawerId = 1
                }
            });

            endorsementsService = new EndorsementsService(endorsementRepository.Object, partyRepositoryWithCount.Object,
                                                          billOfExchangeRepositoryWithCount.Object);
            Assert.Throws <CantReferenceOldEndorsementsException>(() => endorsementsService.GetEndorsementsForBill(1));
        }
Exemplo n.º 3
0
        public void MoreThanOnePreviousEndorsementIsNotSetException()
        {
            var endorsements = new List <Endorsement>
            {
                new Endorsement
                {
                    Id = 2, BillId = 1, NewBeneficiaryId = BillBeneficiaryId, PreviousEndorsementId = null
                },
                new Endorsement
                {
                    Id = 4, BillId = 1, NewBeneficiaryId = BillBeneficiaryId + 1, PreviousEndorsementId = null
                },
                new Endorsement
                {
                    Id = 5, BillId = 1, NewBeneficiaryId = BillBeneficiaryId + 2, PreviousEndorsementId = 4
                }
            };

            endorsementRepository.Setup(x => x.Get(int.MaxValue, 0)).Returns(endorsements);
            partyRepositoryWithCount.Setup(x => x.Get(int.MaxValue, 0)).Returns(new List <Party>()
            {
                ctsTradeItParty, new Party()
                {
                    Id = 2, Name = "TEST PARTY"
                }
            });
            billOfExchangeRepositoryWithCount.Setup(x => x.GetByIds(new List <int>()
            {
                1
            })).Returns(
                new List <BillOfExchange>()
            {
                new BillOfExchange()
                {
                    BeneficiaryId = 3, DrawerId = 1
                }
            });

            endorsementsService = new EndorsementsService(endorsementRepository.Object, partyRepositoryWithCount.Object,
                                                          billOfExchangeRepositoryWithCount.Object);
            Assert.Throws <MoreThanOnePreviousEndorsementIsNotSetException>(() =>
                                                                            endorsementsService.GetEndorsementsForBill(1));
        }