Пример #1
0
        public void MustBeValidStatusTransition_Valid_Succeeds(StandardsApplicableStatus oldStatus, StandardsApplicableStatus newStatus, string role)
        {
            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(role: role));
            var validator = new StandardsApplicableValidator(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object);
            var oldClaim  = Creator.GetStandardsApplicable(status: oldStatus);
            var newClaim  = Creator.GetStandardsApplicable(status: newStatus);

            _claimDatastore.Setup(x => x.ById(newClaim.Id)).Returns(oldClaim);

            validator.MustBeValidStatusTransition();
            var valres = validator.Validate(newClaim);

            valres.Errors.Should().BeEmpty();
        }
Пример #2
0
        public void MustBeValidStatusTransition_Invalid_ReturnsError(StandardsApplicableStatus oldStatus, StandardsApplicableStatus newStatus, string role)
        {
            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(role: role));
            var validator = new StandardsApplicableValidator(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object);
            var oldClaim  = Creator.GetStandardsApplicable(status: oldStatus);
            var newClaim  = Creator.GetStandardsApplicable(status: newStatus);

            _claimDatastore.Setup(x => x.ById(newClaim.Id)).Returns(oldClaim);

            validator.MustBeValidStatusTransition();
            var valres = validator.Validate(newClaim);

            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Invalid Status transition")
            .And
            .HaveCount(1);
        }
Пример #3
0
        public void Validate_Update_FinalState_ReturnsError(
            [Values(
                 StandardsApplicableStatus.Approved,
                 StandardsApplicableStatus.ApprovedPartial,
                 StandardsApplicableStatus.ApprovedFirstOfType,
                 StandardsApplicableStatus.Rejected)]
            StandardsApplicableStatus oldStatus,
            [Values(
                 StandardsApplicableStatus.NotStarted,
                 StandardsApplicableStatus.Draft,
                 StandardsApplicableStatus.Submitted,
                 StandardsApplicableStatus.Remediation,
                 StandardsApplicableStatus.Approved,
                 StandardsApplicableStatus.ApprovedPartial,
                 StandardsApplicableStatus.ApprovedFirstOfType,
                 StandardsApplicableStatus.Rejected)]
            StandardsApplicableStatus newStatus,
            [Values(
                 Roles.Admin,
                 Roles.Buyer,
                 Roles.Supplier)]
            string role)
        {
            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext(role: role));
            var validator = new StandardsApplicableValidator(_context.Object, _logger.Object, _claimDatastore.Object, _contactsDatastore.Object, _solutionsDatastore.Object);
            var oldClaim  = Creator.GetStandardsApplicable(status: oldStatus);
            var newClaim  = Creator.GetStandardsApplicable(status: newStatus);

            _claimDatastore.Setup(x => x.ById(newClaim.Id)).Returns(oldClaim);

            validator.MustBeValidStatusTransition();
            var valres = validator.Validate(newClaim);

            valres.Errors.Should()
            .ContainSingle(x => x.ErrorMessage == "Invalid Status transition")
            .And
            .HaveCount(1);
        }