Пример #1
0
        public void PreviousMustNotBeInUse_InUse_ReturnsError()
        {
            var evidenceId = Guid.NewGuid().ToString();

            // first chain: rev1 <-- rev2
            var rev1 = Creator.GetReviewsBase(evidenceId: evidenceId);
            var rev2 = Creator.GetReviewsBase(evidenceId: evidenceId, prevId: rev1.Id);

            // second chain: revA <-- revB
            var revA = Creator.GetReviewsBase(evidenceId: evidenceId);
            var revB = Creator.GetReviewsBase(evidenceId: evidenceId, prevId: revA.Id);

            // review datastore returns both chains
            _reviewsDatastore.Setup(x => x.ByEvidence(evidenceId))
            .Returns(new[]
            {
                new[] { rev1, rev2 },
                new[] { revA, revB }
            });

            // create new review linked (previous) to rev1 ie 'fan out'
            var review    = Creator.GetReviewsBase(evidenceId: evidenceId, prevId: rev1.Id);
            var validator = new DummyReviewsValidatorBase(_reviewsDatastore.Object, _evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object);


            validator.PreviousMustNotBeInUse();
            var valres = validator.Validate(review);


            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Previous review already in use")
            .And
            .HaveCount(1);
        }
Пример #2
0
        public void PreviousMustNotBeInUse_NotInUse_Succeeds()
        {
            var validator = new DummyReviewsValidatorBase(_reviewsDatastore.Object, _evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object);
            var review    = Creator.GetReviewsBase(prevId: Guid.NewGuid().ToString());

            _reviewsDatastore.Setup(x => x.ByEvidence(review.EvidenceId)).Returns(new[] { new[] { Creator.GetReviewsBase() } });

            validator.PreviousMustNotBeInUse();
            var valres = validator.Validate(review);

            valres.Errors.Should().BeEmpty();
        }