private bool IsTrustSpecialCase(PackStatus packStatus, AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks, CumYesIs cumChecks)
 {
     return(packStatus == PackStatus.Simple &&
            additionalChecks == AdditionalChecks.HasTrust &&
            amountOfStockSubmited == AmountOfStockSubmited.LessOrEqualThanThereIsOnPack &&
            cumChecks == CumYesIs.NotChecked);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Случай для продавца
        /// </summary>
        public static ValidationResult IsSellerAllowedCase(AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited)
        {
            if (additionalChecks == AdditionalChecks.NotWholeStockWasPassed &&
                amountOfStockSubmited == AmountOfStockSubmited.VotesArentSubmited)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.SELLER_PACKET_WITH_NOT_WHOLE_STOCK_PASSED_CHECK_MUST_HAVE_VOTES_SUBMITED));
            }

            var sellerCheckedThatHeHasTrust = additionalChecks.IsSet(AdditionalChecks.HasTrust);

            if (sellerCheckedThatHeHasTrust)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.SELLER_PACK_CANNOT_HAVE_HAVE_TRUST_CHECK));
            }

            var hasInstructionsIsChecked     = additionalChecks.IsSet(AdditionalChecks.HasInstructions);
            var notWholeStockPassedIsChecked = additionalChecks.IsSet(AdditionalChecks.NotWholeStockWasPassed);

            if (!hasInstructionsIsChecked && !notWholeStockPassedIsChecked)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.SELLER_PACKET_MUST_HAVE_NOTWHOLESTOCKWASPASSED_CHECK));
            }

            return(ValidationResult.Fullfilled);
        }
        /// <summary>
        /// Случай для обычного пакета
        /// </summary>
        private static ValidationResult IsSimpleAllowedCase(AdditionalChecks checks, AmountOfStockSubmited amountOfStockSubmited, CumYesIs cumChecks, NumberOfChecks numberOfChecks)
        {
            if (amountOfStockSubmited == AmountOfStockSubmited.VotesArentSubmited)
            {
                if (cumChecks == CumYesIs.NotChecked)
                {
                    return(ValidationResult.Fullfilled);
                }
                else
                {
                    return(ValidationResult.NotFullfilled(ErrorTexts.CUMULATIVE_QUESTION_MUST_HAVE_VOTES_SUBMITED_IN_CASE_OF_YES_CHECK));
                }
            }

            if (checks.IsSet(AdditionalChecks.HasTrust))
            {
                if (checks.IsSet(AdditionalChecks.HasInstructions) ||
                    checks.IsSet(AdditionalChecks.NotWholeStockWasPassed))
                {
                    //Установлен только вариант "ЗА"
                    if (cumChecks == CumYesIs.Checked && numberOfChecks == NumberOfChecks.Single)
                    {
                        return(ValidationResult.Fullfilled);
                    }
                    else
                    {
                        return(ValidationResult.NotFullfilled(ErrorTexts.INCORRECT_FILLING));
                    }
                }
            }
            return(ValidationResult.Fullfilled);
        }
Exemplo n.º 4
0
        private static void HandleTrustExistanceSpecialCase(PackStatus packStatus, AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks)
        {
            var chain1 = GraphProvider.GetQSimpleQSepAndHierSubQTableRuleChain(null, null,
                                                                               () => packStatus,
                                                                               () => true,
                                                                               () => amountOfStockSubmited,
                                                                               () => numberOfChecks,
                                                                               () => additionalChecks,
                                                                               () => false
                                                                               );

            Assert.That(RuleChainFulfilledResoveHelper.RuleChainIsFulfilled(chain1), Is.EqualTo(true));


            var chain2 = GraphProvider.GetQSimpleQSepAndHierSubQTableRuleChain(null, null,
                                                                               () => packStatus,
                                                                               () => false,
                                                                               () => amountOfStockSubmited,
                                                                               () => numberOfChecks,
                                                                               () => additionalChecks,
                                                                               () => false
                                                                               );

            Assert.That(RuleChainFulfilledResoveHelper.RuleChainIsFulfilled(chain2), Is.EqualTo(false));
        }
 private static bool IsExceptionalCaseForSimplePack(AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks, CumYesIs cumChecks)
 {
     return(additionalChecks == AdditionalChecks.None  /*&&
                                                        * amountOfStockSubmited == AmountOfStockSubmited.MoreThanThereIsOnPack*/
            &&
            numberOfChecks == NumberOfChecks.Single &&
            cumChecks == CumYesIs.NotChecked);
 }
 private static bool IsTrustSpecialCase(PackStatus packStatus, AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks)
 {
     //—пециальный случай дл¤ проверки наличи¤ доверенности
     return(packStatus == PackStatus.Simple &&
            additionalChecks == AdditionalChecks.HasTrust &&
            amountOfStockSubmited == AmountOfStockSubmited.LessOrEqualThanThereIsOnPack &&
            numberOfChecks == NumberOfChecks.Single);
 }
Exemplo n.º 7
0
        public static bool IsMultiVariantVotingAllowed(AdditionalChecks additionalChecks)
        {
            var allowedVariants = new List <AdditionalChecks>
            {
                AdditionalChecks.HasInstructions,
                AdditionalChecks.HasInstructions | AdditionalChecks.NotWholeStockWasPassed,
                AdditionalChecks.HasInstructions | AdditionalChecks.HasTrust
            };

            return(allowedVariants.Contains(additionalChecks));
        }
 public string GetErrorTextFor(PackStatus packStatus, AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks, CumYesIs cumChecks, bool trustExists)
 {
     return
         (GetIsValidationResultFor(packStatus,
                                   additionalChecks,
                                   amountOfStockSubmited,
                                   numberOfChecks,
                                   cumChecks,
                                   trustExists)
          .ErrorText);
 }
 // Важно! Для корректной работы, если не указаны голоса для варианта "ЗА" всегда amountOfStockSubmited должно
 // быть равно VotesArentSubmited, иначе могут случиться неприятности в случае NumberOfChecks.Multiple, когда
 // выбран вариант "ЗА" без указания голосов и "ПРОТИВ" с указанием ("ЗА" всегда должен иметь количество голосов
 // указанным).
 public bool GetIsFulfilledFor(PackStatus packStatus, AdditionalChecks additionalChecks, AmountOfStockSubmited amountOfStockSubmited, NumberOfChecks numberOfChecks, CumYesIs cumChecks, bool trustExists)
 {
     return
         (GetIsValidationResultFor(packStatus,
                                   additionalChecks,
                                   amountOfStockSubmited,
                                   numberOfChecks,
                                   cumChecks,
                                   trustExists)
          .IsFullfilled);
 }
        /// <summary>
        /// —лучай дл¤ обычного пакета
        /// </summary>
        private static ValidationResult IsSimpleAllowedCase(AdditionalChecks checks, AmountOfStockSubmited amountOfStockSubmited)
        {
            if (amountOfStockSubmited == AmountOfStockSubmited.VotesArentSubmited)
            {
                return(ValidationResult.Fullfilled);
            }

            if (checks.IsSet(AdditionalChecks.HasTrust))
            {
                if (checks.IsSet(AdditionalChecks.HasInstructions) ||
                    checks.IsSet(AdditionalChecks.NotWholeStockWasPassed))
                {
                    return(ValidationResult.NotFullfilled(ErrorTexts.CANNOT_USE_OTHER_CHECKS_WITH_HAVE_TRUST_CHECK));
                }
            }
            return(ValidationResult.Fullfilled);
        }
        private ValidationResult GetValidationResultFor(PackStatus packStatus,
                                                        AdditionalChecks additionalChecks,
                                                        AmountOfStockSubmited amountOfStockSubmited,
                                                        NumberOfChecks numberOfChecks,
                                                        bool trustExists)
        {
            var ammountOfStockSubmitedIsNoMorethatThereIsOnPack = AmmountOfStockSubmitedIsNoMorethatThereIsOnPack(amountOfStockSubmited);

            if (!ammountOfStockSubmitedIsNoMorethatThereIsOnPack.IsFullfilled)
            {
                return(ammountOfStockSubmitedIsNoMorethatThereIsOnPack);
            }


            var multipleChecksArentSelectedIfVotesArentSubmited = MultipleChecksArentSelectedIfVotesArentSubmited(amountOfStockSubmited, numberOfChecks);

            if (!multipleChecksArentSelectedIfVotesArentSubmited.IsFullfilled)
            {
                return(multipleChecksArentSelectedIfVotesArentSubmited);
            }

            if (IsTrustSpecialCase(packStatus, additionalChecks, amountOfStockSubmited, numberOfChecks))
            {
                return(IsAllowedTrustSpecialCase(trustExists));
            }

            if (packStatus == PackStatus.Simple)
            {
                return(IsSimpleAllowedCase(additionalChecks, amountOfStockSubmited));
            }

            if (packStatus == PackStatus.Seller)
            {
                return(BuyerAndSellerAllowedCasesHelper.IsSellerAllowedCase(additionalChecks, amountOfStockSubmited));
            }

            if (packStatus == PackStatus.Buyer)
            {
                return(BuyerAndSellerAllowedCasesHelper.IsBuyerAllowedCase(additionalChecks, amountOfStockSubmited));
            }

            throw new NotSupportedException("“ип " + packStatus + " не поддерживаетс¤.");
        }
Exemplo n.º 12
0
        /// <summary>
        /// Случай для покупателя
        /// </summary>
        public static ValidationResult IsBuyerAllowedCase(AdditionalChecks checks, AmountOfStockSubmited amountOfStockSubmited)
        {
            var buyerHasTrust         = checks.IsSet(AdditionalChecks.HasTrust);
            var buyerHasSumbitedVotes = amountOfStockSubmited != AmountOfStockSubmited.VotesArentSubmited;
            var buyerHasntCheckedNotWholeStockWasPassed = !checks.IsSet(AdditionalChecks.NotWholeStockWasPassed);

            if (!buyerHasTrust)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.BUYERS_PACK_MUST_HAVE_HAVE_TRUST_CHECK));
            }
            if (!buyerHasSumbitedVotes)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.BUYERS_PACK_MUST_HAVE_VOTES_SUBMITED));
            }
            if (!buyerHasntCheckedNotWholeStockWasPassed)
            {
                return(ValidationResult.NotFullfilled(ErrorTexts.BUYERS_PACK_CANNOT_HAVE_NOTWHOLESTOCKPASSED_CHECK));
            }

            return(ValidationResult.Fullfilled);
        }
Exemplo n.º 13
0
        public void MatrixTest(Status status,
                               AdditionalChecks additionalChecks,
                               AmountOfStockSubmited amountOfStockSubmited,
                               NumberOfChecks numberOfChecks,
                               bool expected)
        {
            var packStatus = GetPackStatusFor(status);

            // Специальный случай для голосования по доверенности
            if (packStatus == PackStatus.Simple &&
                additionalChecks == AdditionalChecks.HasTrust &&
                amountOfStockSubmited == AmountOfStockSubmited.LessOrEqualThanThereIsOnPack &&
                numberOfChecks == NumberOfChecks.Single)
            {
                HandleTrustExistanceSpecialCase(packStatus, additionalChecks, amountOfStockSubmited, numberOfChecks);
                return;
            }
            var chain1 = GraphProvider.GetQSimpleQSepAndHierSubQTableRuleChain(null, null,
                                                                               () => packStatus,
                                                                               () => true,
                                                                               () => amountOfStockSubmited,
                                                                               () => numberOfChecks,
                                                                               () => additionalChecks,
                                                                               () => false);
            var chain2 = GraphProvider.GetQSimpleQSepAndHierSubQTableRuleChain(null, null,
                                                                               () => packStatus,
                                                                               () => false,
                                                                               () => amountOfStockSubmited,
                                                                               () => numberOfChecks,
                                                                               () => additionalChecks,
                                                                               () => false);



            Assert.That(RuleChainFulfilledResoveHelper.RuleChainIsFulfilled(chain1), Is.EqualTo(expected));
            Assert.That(RuleChainFulfilledResoveHelper.RuleChainIsFulfilled(chain2), Is.EqualTo(expected));
        }
Exemplo n.º 14
0
 /// <summary>
 /// Является ли особенным случаем для простого пакета
 /// </summary>
 private static bool IsExceptionalCaseForSimple(AdditionalChecks additionalChecks, NumberOfChecks checks)
 {
     return(additionalChecks == AdditionalChecks.None && checks == NumberOfChecks.Single);
 }