public void ClaimedStandardEvidencePreviousVersionMustBelongToSolution_Valid_Succeeds()
        {
            var validator = new SolutionsExValidator(_context.Object, _logger.Object, _solutionsValidator.Object);
            var soln      = Creator.GetSolutionEx();
            var claimEv1  = Creator.GetStandardsApplicableEvidence();
            var claimEv2  = Creator.GetStandardsApplicableEvidence(prevId: claimEv1.Id);

            soln.ClaimedStandardEvidence = new List <StandardsApplicableEvidence>(new[] { claimEv1, claimEv2 });

            validator.ClaimedStandardEvidencePreviousVersionMustBelongToSolution();
            var valres = validator.Validate(soln);

            valres.Errors.Should().BeEmpty();
        }
        public void SolutionMustBeInReview_Review_Succeeds(SolutionStatus status)
        {
            var validator = new StandardsApplicableEvidenceValidator(_evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object);
            var soln      = Creator.GetSolution(status: status);
            var claim     = Creator.GetStandardsApplicable(solnId: soln.Id);
            var evidence  = Creator.GetStandardsApplicableEvidence(claimId: claim.Id);

            _claimDatastore.As <IClaimsDatastore <ClaimsBase> >().Setup(x => x.ById(evidence.ClaimId)).Returns(claim);
            _solutionDatastore.Setup(x => x.ById(soln.Id)).Returns(soln);

            validator.SolutionMustBeInReview();
            var valres = validator.Validate(evidence);

            valres.Errors.Should().BeEmpty();
        }
        public void ClaimedStandardReviewMustBelongToEvidence_Valid_Succeeds()
        {
            var validator = new SolutionsExValidator(_context.Object, _logger.Object, _solutionsValidator.Object);
            var soln      = Creator.GetSolutionEx();
            var claimEv   = Creator.GetStandardsApplicableEvidence();
            var review    = Creator.GetStandardsApplicableReviews(evidenceId: claimEv.Id);

            soln.ClaimedStandardEvidence = new List <StandardsApplicableEvidence>(new[] { claimEv });
            soln.ClaimedStandardReview   = new List <StandardsApplicableReviews>(new[] { review });

            validator.ClaimedStandardReviewMustBelongToEvidence();
            var valres = validator.Validate(soln);

            valres.Errors.Should().BeEmpty();
        }
        public void ClaimedStandardEvidencePreviousVersionMustBelongToSolution_Invalid_ReturnsError()
        {
            var validator = new SolutionsExValidator(_context.Object, _logger.Object, _solutionsValidator.Object);
            var soln      = Creator.GetSolutionEx();
            var claimEv1  = Creator.GetStandardsApplicableEvidence();
            var claimEv2  = Creator.GetStandardsApplicableEvidence(prevId: Guid.NewGuid().ToString());

            soln.ClaimedStandardEvidence = new List <StandardsApplicableEvidence>(new[] { claimEv1, claimEv2 });

            validator.ClaimedStandardEvidencePreviousVersionMustBelongToSolution();
            var valres = validator.Validate(soln);

            valres.Errors.Should()
            .Contain(x => x.ErrorMessage == "ClaimedStandardEvidence previous version must belong to solution")
            .And
            .HaveCount(1);
        }
        public void SolutionMustBeInReview_NonReview_ReturnsError(SolutionStatus status)
        {
            var validator = new StandardsApplicableEvidenceValidator(_evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object);
            var soln      = Creator.GetSolution(status: status);
            var claim     = Creator.GetStandardsApplicable(solnId: soln.Id);
            var evidence  = Creator.GetStandardsApplicableEvidence(claimId: claim.Id);

            _claimDatastore.As <IClaimsDatastore <ClaimsBase> >().Setup(x => x.ById(evidence.ClaimId)).Returns(claim);
            _solutionDatastore.Setup(x => x.ById(soln.Id)).Returns(soln);

            validator.SolutionMustBeInReview();
            var valres = validator.Validate(evidence);

            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Can only add evidence if solution is in review")
            .And
            .HaveCount(1);
        }
        public void ClaimedStandardReviewMustBelongToEvidence_Invalid_ReturnsError()
        {
            var validator = new SolutionsExValidator(_context.Object, _logger.Object, _solutionsValidator.Object);
            var soln      = Creator.GetSolutionEx();
            var claimEv   = Creator.GetStandardsApplicableEvidence();
            var review    = Creator.GetStandardsApplicableReviews();

            soln.ClaimedStandardEvidence = new List <StandardsApplicableEvidence>(new[] { claimEv });
            soln.ClaimedStandardReview   = new List <StandardsApplicableReviews>(new[] { review });

            validator.ClaimedStandardReviewMustBelongToEvidence();
            var valres = validator.Validate(soln);

            valres.Errors.Should()
            .Contain(x => x.ErrorMessage == "ClaimedStandardReview must belong to evidence")
            .And
            .HaveCount(1);
        }