public void MustBeValidSolutionId_Valid_Succeeds() { var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(); validator.MustBeValidSolutionId(); var valres = validator.Validate(claim); valres.Errors.Should().BeEmpty(); }
public void MustBeSameSolution_Same_Succeeds() { var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(); _claimDatastore.Setup(x => x.ById(claim.Id)).Returns(claim); validator.MustBeSameSolution(); var valres = validator.Validate(claim); valres.Errors.Should().BeEmpty(); }
public void MustBeValidId_NotGuid_ReturnsError() { var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(id: "some other Id"); validator.MustBeValidId(); var valres = validator.Validate(claim); valres.Errors.Should() .ContainSingle(x => x.ErrorMessage == "Invalid Id") .And .HaveCount(1); }
public void MustBeSameOrganisation_Same_NewClaim_Succeeds() { var orgId = Guid.NewGuid().ToString(); _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(orgId: orgId)); var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(); _solutionsDatastore.Setup(x => x.ById(claim.SolutionId)).Returns(Creator.GetSolution(orgId: orgId)); validator.MustBeSameOrganisation(); var valres = validator.Validate(claim); valres.Errors.Should().BeEmpty(); }
public void MustBeSameSolution_Different_ReturnsError() { var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(); _claimDatastore.Setup(x => x.ById(claim.Id)).Returns(Creator.GetClaimsBase()); validator.MustBeSameSolution(); var valres = validator.Validate(claim); valres.Errors.Should() .ContainSingle(x => x.ErrorMessage == "Cannot transfer claim between solutions") .And .HaveCount(1); }
public void MustBeValidSolutionId_Null_ReturnsError() { var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var claim = Creator.GetClaimsBase(); claim.SolutionId = null; validator.MustBeValidSolutionId(); var valres = validator.Validate(claim); valres.Errors.Should() .ContainSingle(x => x.ErrorMessage == "Invalid SolutionId") .And .ContainSingle(x => x.ErrorMessage == "'Solution Id' must not be empty.") .And .HaveCount(2); }
public void ContactMustBeSameOrganisation_Different_ReturnsError() { var orgId = Guid.NewGuid().ToString(); _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(orgId: orgId)); var validator = new DummyClaimsValidatorBase(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object); var contact = Creator.GetContact(orgId: orgId); var claim = Creator.GetClaimsBase(); _contactsDatastore.Setup(x => x.ById(contact.Id)).Returns(contact); validator.OwnerMustBeSameOrganisation(); var valres = validator.Validate(claim); valres.Errors.Should() .ContainSingle(x => x.ErrorMessage == "Contact must be from organisation") .And .HaveCount(1); }