public void MustBeFromSameOrganisation_Same_Succeeds() { var orgId = Guid.NewGuid().ToString(); var validator = new DummyReviewsValidatorBase(_reviewsDatastore.Object, _evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object); var review = Creator.GetReviewsBase(); _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(orgId: orgId)); var soln = Creator.GetSolution(orgId: orgId); var claim = Creator.GetClaimsBase(solnId: soln.Id); var evidence = Creator.GetEvidenceBase(claimId: claim.Id); _evidenceDatastore.Setup(x => x.ById(review.EvidenceId)).Returns(evidence); _claimDatastore.Setup(x => x.ById(evidence.ClaimId)).Returns(claim); _solutionDatastore.Setup(x => x.ById(soln.Id)).Returns(soln); validator.MustBeFromSameOrganisation(); var valres = validator.Validate(review); valres.Errors.Should().BeEmpty(); }
public void MustBeFromSameOrganisation_Other_ReturnsError() { var orgId = Guid.NewGuid().ToString(); _context.Setup(x => x.HttpContext).Returns(Creator.GetContext()); var validator = new DummyReviewsValidatorBase(_reviewsDatastore.Object, _evidenceDatastore.Object, _claimDatastore.Object, _solutionDatastore.Object, _context.Object, _logger.Object); var review = Creator.GetReviewsBase(); var soln = Creator.GetSolution(orgId: orgId); var claim = Creator.GetClaimsBase(solnId: soln.Id); var evidence = Creator.GetEvidenceBase(); _evidenceDatastore.Setup(x => x.ById(review.EvidenceId)).Returns(evidence); _claimDatastore.Setup(x => x.ById(evidence.ClaimId)).Returns(claim); _solutionDatastore.Setup(x => x.ById(soln.Id)).Returns(soln); validator.MustBeFromSameOrganisation(); var valres = validator.Validate(review); valres.Errors.Should() .ContainSingle(x => x.ErrorMessage == "Must be from same organisation") .And .HaveCount(1); }