public void IfNoEndorsementForBillExistsOnlyOwnerShouldBeBillBeneficiary()
        {
            var billOfExchange = new BillOfExchange {
                BeneficiaryId = BillBeneficiaryId, DrawerId = 2
            };

            billOfExchangeRepositoryWithCount.Setup(x => x.GetByBeneficiaryIds(It.IsAny <List <int> >()))
            .Returns(new List <IEnumerable <BillOfExchange> >
            {
                new List <BillOfExchange>
                {
                    billOfExchange
                }
            });
            endorsementRepository.Setup(x => x.GetByBillIds(It.IsAny <List <int> >()))
            .Returns(new List <IEnumerable <Endorsement> >());
            endorsementRepository.Setup(x => x.GetByNewBeneficiaryIds(It.IsAny <List <int> >()))
            .Returns(new List <IEnumerable <Endorsement> >());

            var billOfExchangeSvc =
                new BillOfExchangeService(billOfExchangeRepositoryWithCount.Object, mapper,
                                          partyRepositoryWithCount.Object, endorsementRepository.Object);
            IEnumerable <BillOfExchangeDto>
            billOfExchanges = billOfExchangeSvc.GetBillsByOwner(It.IsAny <int>()).ToList();

            billOfExchanges.ShouldNotBeEmpty();
            billOfExchanges.FirstOrDefault().BeneficiaryId = BillBeneficiaryId;
        }
        public void IfEndorsementsForBillExistsOwnerShouldTheLastEndorsementBeneficiary()
        {
            billOfExchangeRepositoryWithCount.Setup(x => x.GetByBeneficiaryIds(It.IsAny <List <int> >()))
            .Returns(new List <IEnumerable <BillOfExchange> >());
            var endorsements = new List <Endorsement>
            {
                new Endorsement {
                    Id = 1, BillId = 2
                },
                new Endorsement {
                    Id = 2, BillId = 2, NewBeneficiaryId = 1
                },
                new Endorsement {
                    Id = 3, BillId = 1, NewBeneficiaryId = 2
                },
                new Endorsement {
                    Id = 4, NewBeneficiaryId = BillBeneficiaryId, BillId = 1
                }
            };

            endorsementRepository.Setup(x => x.GetByNewBeneficiaryIds(It.IsAny <IReadOnlyList <int> >()))
            .Returns(new List <IEnumerable <Endorsement> >()
            {
                endorsements
            });
            endorsementRepository.Setup(x => x.GetByBillIds(It.IsAny <IReadOnlyList <int> >()))
            .Returns(new List <IEnumerable <Endorsement> >()
            {
                endorsements
            });
            billOfExchangeRepositoryWithCount
            .Setup(x => x.GetByIds(new List <int>()
            {
                BillBeneficiaryId
            })).Returns(
                new List <BillOfExchange>
            {
                new BillOfExchange {
                    BeneficiaryId = BillBeneficiaryId, DrawerId = 2
                }
            });

            var billOfExchangeSvc =
                new BillOfExchangeService(billOfExchangeRepositoryWithCount.Object, mapper,
                                          partyRepositoryWithCount.Object, endorsementRepository.Object);
            List <BillOfExchangeDto> billOfExchanges = billOfExchangeSvc.GetBillsByOwner(BillBeneficiaryId).ToList();

            billOfExchanges.ShouldNotBeEmpty();
            billOfExchanges.FirstOrDefault().BeneficiaryId = BillBeneficiaryId;
        }