public void ShouldGetTheCorrectApplicationCount(int applicationCount)
        {
            SetupApplicationClaimSets("OtherApplication");

            var testClaimSets = SetupApplicationClaimSets();

            Transaction <SqlServerUsersContext>(usersContext =>
            {
                foreach (var claimSet in testClaimSets)
                {
                    foreach (var _ in Enumerable.Range(1, applicationCount))
                    {
                        usersContext.Applications.Add(new VendorApplication
                        {
                            ApplicationName       = $"TestAppVendorName{Guid.NewGuid():N}",
                            ClaimSetName          = claimSet.ClaimSetName,
                            OperationalContextUri = OperationalContext.DefaultOperationalContextUri
                        });
                    }
                }

                usersContext.SaveChanges();

                var query   = new GetClaimSetsByApplicationNameQuery(TestContext, usersContext);
                var results = query.Execute(testClaimSets.First().Application.ApplicationName).ToArray();

                results.Length.ShouldBe(testClaimSets.Count);
                results.Select(x => x.Name).ShouldBe(testClaimSets.Select(x => x.ClaimSetName), true);
                results.Select(x => x.ApplicationsCount).Distinct().Single().ShouldBe(applicationCount);
            });
        }
        public void ShouldExcludeSystemReservedClaimSets()
        {
            var testClaimSets = SetupApplicationClaimSets();

            var testApplication = testClaimSets.First().Application;

            Save(new ClaimSet
            {
                ClaimSetName = "Bootstrap Descriptors and EdOrgs",
                Application  = testApplication
            });

            Save(new ClaimSet
            {
                ClaimSetName = CloudOdsAdminApp.InternalAdminAppClaimSet,
                Application  = testApplication
            });

            Transaction <SqlServerUsersContext>(usersContext =>
            {
                var query   = new GetClaimSetsByApplicationNameQuery(TestContext, usersContext);
                var results = query.Execute(testApplication.ApplicationName).ToArray();

                results.ShouldNotContain(x => x.Name == CloudOdsAdminApp.InternalAdminAppClaimSet);
                results.ShouldNotContain(x => x.Name == "Bootstrap Descriptors and EdOrgs");
            });
        }
        public void ShouldGetAllTheClaimSetsFromAnApplication()
        {
            var testClaimSets = SetupApplicationClaimSets();

            Transaction <SqlServerUsersContext>(usersContext =>
            {
                var query   = new GetClaimSetsByApplicationNameQuery(TestContext, usersContext);
                var results = query.Execute(testClaimSets.First().Application.ApplicationName).ToArray();

                results.Length.ShouldBe(testClaimSets.Count);
                results.Select(x => x.Name).ShouldBe(testClaimSets.Select(x => x.ClaimSetName), true);
            });
        }
        public void ShouldGetTheClaimSetsWithTheExpectedIsEditableValue()
        {
            var testClaimSets   = SetupApplicationClaimSets();
            var testApplication = testClaimSets.First().Application;

            Save(new ClaimSet
            {
                ClaimSetName = "SIS Vendor",
                Application  = testApplication
            });

            Transaction <SqlServerUsersContext>(usersContext =>
            {
                var query   = new GetClaimSetsByApplicationNameQuery(TestContext, usersContext);
                var results = query.Execute(testApplication.ApplicationName).ToArray();

                results.Count(x => x.IsEditable).ShouldBe(testClaimSets.Count);
                results.Single(x => !x.IsEditable).Name.ShouldBe("SIS Vendor");
                results.Count(x => !x.IsEditable).ShouldBe(1);
            });
        }