public void ShouldNotDeleteClaimSetHasAnAssociatedApplication()
        {
            var testApplication = new Application
            {
                ApplicationName = "TestApplication3"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet {
                ClaimSetName = $"TestClaimSet{DateTime.Now:O}", Application = testApplication
            };

            Save(testClaimSet);

            var claimSetToDelete = new DeleteClaimSetModel()
            {
                Name                   = testClaimSet.ClaimSetName,
                Id                     = testClaimSet.ClaimSetId,
                IsEditable             = true,
                VendorApplicationCount = 1
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new DeleteClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(claimSetToDelete);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe($"Cannot delete this claim set. This claim set has {claimSetToDelete.VendorApplicationCount} associated application(s).");
            });
        }
        public void ShouldNotDeleteClaimSetIfNotEditable()
        {
            var testApplication = new Application
            {
                ApplicationName = "TestApplication1"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet {
                ClaimSetName = $"TestClaimSet{DateTime.Now:O}", Application = testApplication
            };

            Save(testClaimSet);

            var claimSetToDelete = new DeleteClaimSetModel()
            {
                Name       = testClaimSet.ClaimSetName,
                Id         = testClaimSet.ClaimSetId,
                IsEditable = false
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new DeleteClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(claimSetToDelete);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe("Only user created claim sets can be deleted");
            });
        }
        public void ShouldNotDeleteClaimSetIfNotAnExistingId()
        {
            var testApplication = new Application
            {
                ApplicationName = "TestApplication2"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet {
                ClaimSetName = $"TestClaimSet{DateTime.Now:O}", Application = testApplication
            };

            Save(testClaimSet);

            var claimSetToDelete = new DeleteClaimSetModel()
            {
                Name       = testClaimSet.ClaimSetName,
                Id         = 99,
                IsEditable = true
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new DeleteClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(claimSetToDelete);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe("No such claim set exists in the database");
            });
        }