Example #1
0
        public void CheckListTest_EmptyList()
        {
            // arrange
            var checkListFixture   = new CheckListFixture();
            var endorsementChecker = new EndorsementChecker();

            // act
            EndorsementCheckResult result = endorsementChecker.CheckList(checkListFixture.BillOfExchange, checkListFixture.EndorsementList);

            // assert
            Assert.IsTrue(result.IsCorrect);
        }
Example #2
0
        public void CheckListTest_TwoFirst()
        {
            // arrange
            CheckListFixture checkListFixture = new CheckListFixture().AddFirstEndorsement(1, false).AddFirstEndorsement(2, false);
            var endorsementChecker            = new EndorsementChecker();

            // act
            EndorsementCheckResult result = endorsementChecker.CheckList(checkListFixture.BillOfExchange, checkListFixture.EndorsementList);

            // assert
            Assert.IsFalse(result.IsCorrect);
            CollectionAssert.AreEquivalent(checkListFixture.WrongEndorsementList, result.WrongEndorsements);
        }
Example #3
0
        public void CheckListTest_SecondHaveSamelBeneficiaryId()
        {
            // arrange
            CheckListFixture checkListFixture = new CheckListFixture()
                                                .AddFirstEndorsement(1)
                                                .AppendEndorsement(CheckListFixture.BillBeneficiaryId)
                                                .AppendEndorsement(3);
            var endorsementChecker = new EndorsementChecker();

            // act
            EndorsementCheckResult result = endorsementChecker.CheckList(checkListFixture.BillOfExchange, checkListFixture.EndorsementList);

            // assert
            Assert.IsTrue(result.IsCorrect);
        }
Example #4
0
        public void CheckListTest_FirstHaveSamelBeneficiaryId()
        {
            // arrange
            CheckListFixture checkListFixture = new CheckListFixture()
                                                .AddFirstEndorsement(CheckListFixture.BillBeneficiaryId, false)
                                                .AppendEndorsement(2)
                                                .AppendEndorsement(3);
            var endorsementChecker = new EndorsementChecker();

            // act
            EndorsementCheckResult result = endorsementChecker.CheckList(checkListFixture.BillOfExchange, checkListFixture.EndorsementList);

            // assert
            Assert.IsFalse(result.IsCorrect);
            CollectionAssert.AreEquivalent(checkListFixture.WrongEndorsementList, result.WrongEndorsements);
        }
        public List <EndorsmentListDto> GetByBillOfExhange(int billOfExhangeId)
        {
            IEnumerable <Endorsement> list = EndorsementRepository.GetByBillIds(new List <int> {
                billOfExhangeId
            }).FirstOrDefault()?.ToList() ?? new List <Endorsement>();
            BillOfExchange billOfExchange = BillOfExchangeRepository.GetByIds(new List <int> {
                billOfExhangeId
            }).First();

            var partyNamesDictionary = PartyRepository.GetByIds(list.Select(l => l.NewBeneficiaryId).Distinct().ToList()).ToDictionary(p => p.Id, p => p.Name);

            EndorsementCheckResult result = EndorsementChecker.CheckList(billOfExchange, list);

            if (!result.IsCorrect)
            {
                throw new Exception(result.Message);
            }
            return(list.Select(e => new EndorsmentListDto(e.Id, e.NewBeneficiaryId, partyNamesDictionary[e.NewBeneficiaryId])).ToList());
        }
Example #6
0
        public void CheckListTest_SecondCyclicficiaryId()
        {
            // arrange
            CheckListFixture checkListFixture = new CheckListFixture()
                                                .AddFirstEndorsement(1)
                                                .AppendEndorsement(2)
                                                .AppendEndorsement(3)
                                                .AppendEndorsement(4);

            checkListFixture = checkListFixture.AppendEndorsement(5, checkListFixture.EndorsementList.Skip(1).First().Id, false);
            var endorsementChecker = new EndorsementChecker();

            // act
            EndorsementCheckResult result = endorsementChecker.CheckList(checkListFixture.BillOfExchange, checkListFixture.EndorsementList);

            // assert
            Assert.IsFalse(result.IsCorrect);
            CollectionAssert.AreEquivalent(checkListFixture.WrongEndorsementList, result.WrongEndorsements);
        }