public void ShouldNotEditClaimSetIfNameNotUnique()
        {
            var testApplication = new Application
            {
                ApplicationName = $"Test Application {DateTime.Now:O}"
            };

            Save(testApplication);

            var alreadyExistingClaimSet = new ClaimSet {
                ClaimSetName = "TestClaimSet1", Application = testApplication
            };

            Save(alreadyExistingClaimSet);

            var testClaimSet = new ClaimSet {
                ClaimSetName = "TestClaimSet2", Application = testApplication
            };

            Save(testClaimSet);

            var editModel = new EditClaimSetModel {
                ClaimSetName = "TestClaimSet1", ClaimSetId = testClaimSet.ClaimSetId
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new EditClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(editModel);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe("A claim set with this name already exists in the database. Please enter a unique name.");
            });
        }
        public void ShouldNotEditClaimSetIfNameEmpty()
        {
            var testApplication = new Application
            {
                ApplicationName = $"Test Application {DateTime.Now:O}"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet {
                ClaimSetName = "TestClaimSet1", Application = testApplication
            };

            Save(testClaimSet);

            var editModel = new EditClaimSetModel {
                ClaimSetName = "", ClaimSetId = testClaimSet.ClaimSetId
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new EditClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(editModel);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe("'Claim Set Name' must not be empty.");
            });
        }
        public void ShouldNotEditClaimSetIfNameLengthGreaterThan255Characters()
        {
            var testApplication = new Application
            {
                ApplicationName = $"Test Application {DateTime.Now:O}"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet {
                ClaimSetName = "TestClaimSet1", Application = testApplication
            };

            Save(testClaimSet);

            var editModel = new EditClaimSetModel {
                ClaimSetName = "ThisIsAClaimSetWithNameLengthGreaterThan255CharactersThisIsAClaimSetWithNameLengthGreaterThan255CharactersThisIsAClaimSetWithNameLengthGreaterThan255CharactersThisIsAClaimSetWithNameLengthGreaterThan255CharactersThisIsAClaimSetWithNameLengthGreaterThan255CharactersThisIsAClaimSetWithNameLengthGreaterThan255Characters", ClaimSetId = testClaimSet.ClaimSetId
            };

            Scoped <ISecurityContext>(securityContext =>
            {
                var validator         = new EditClaimSetModelValidator(securityContext);
                var validationResults = validator.Validate(editModel);
                validationResults.IsValid.ShouldBe(false);
                validationResults.Errors.Single().ErrorMessage.ShouldBe("The claim set name must be less than 255 characters.");
            });
        }