public void InvokeCanUseValidExcelFile(
     ConvertToClaimRulesCommand sut
 )
 {
     Assert.DoesNotThrow(() => {
         foreach (var result in sut.Invoke()) { }
     }
     );
 }
        public void InvokeDoesNotReturnUnmarkedRecords(
            string permissionUri,
            string permissionValue,
            string role,
            ConvertToClaimRulesCommand sut
            )
        {
            var actual = sut.Invoke<RolePermissionClaimRule>()
                .Where(cr =>
                    cr.Permission.AbsoluteUri == permissionUri
                    && cr.Value == permissionValue
                    && cr.Role == role
                )
                .Any();

            Assert.False(actual);
        }
 public void InvokeReturnsCorrectNumberOfRecords(
     ConvertToClaimRulesCommand sut
 )
 {
     Assert.Equal(60, sut.Invoke().OfType<RolePermissionClaimRule>().Count());
 }
        public void PermissionTitlesAreReadCorrectly(
            string permissionUri,
            string permissionValue,
            string permissionTitle,
            ConvertToClaimRulesCommand sut
            )
        {
            sut.RoleAssignmentFile = ConvertToClaimRulesCommandTest.updatedLayoutFileWithRolesForAllPermissions;
            sut.PermissionsUriPrefix = "http://schemas.danskeregioner.dk/2013/10/identity/claims/rettighed/ppj/";
            sut.PermissionIdsStartCell = new GridCoordinate(5, 0);
            sut.PermissionsShortNameColumnIndex = 1;
            sut.PermissionsTitleColumnIndex = 2;
            sut.RoleValuesStartCell = new GridCoordinate(2, 10);

            var claimRules = sut.Invoke<RolePermissionClaimRule>().ToList();
            var actual = sut.Permissions
                .Where(perm =>
                    perm.Uri.AbsoluteUri == permissionUri
                    && perm.ShortName == permissionValue
                )
                .Single()
                .Title;
            var claimRule = claimRules
                .Where(cr => cr.Permission.AbsoluteUri == permissionUri)
                .Where(cr => cr.Value == permissionValue)
                .Single();

            Assert.Equal(permissionTitle, actual);
            Assert.Equal(claimRule.Title, actual);
        }
        public void InvokeThrowsWhenDuplicateRoleNamesExist(
            ConvertToClaimRulesCommand sut
            )
        {
            sut.RoleAssignmentFile = ConvertToClaimRulesCommandTest.duplicateRoleNamesFile;

            Assert.Throws<InvalidDataException>(() =>
                sut.Invoke<RolePermissionClaimRule>().ToList()
            );
        }
 public void InvokeReturnsRecords(
     ConvertToClaimRulesCommand sut
 )
 {
     Assert.NotEqual(0, sut.Invoke().OfType<RolePermissionClaimRule>().Count());
 }
        public void InvokeReturnsNoRecordsForEmptyAssignmentsFile(
            ConvertToClaimRulesCommand sut
        )
        {
            sut.RoleAssignmentFile = ConvertToClaimRulesCommandTest.noPermissionAssignmentsFile;

            Assert.Equal(0, sut.Invoke().OfType<RolePermissionClaimRule>().Count());
        }
        public void InvokeReturnsCorrectRecords(
            string permissionUri,
            string permissionValue,
            string title,
            string role,
            ConvertToClaimRulesCommand sut
            )
        {
            var claimRules = sut.Invoke<RolePermissionClaimRule>().ToList();
            var actual = claimRules
                .Where(cr =>
                    cr.Permission.AbsoluteUri == permissionUri
                    && cr.Value == permissionValue
                    && cr.Title == title
                    && cr.Role == role
                )
                .Count();

            Assert.Equal(1, actual);
        }
        public void InvokeReturnsCorrectNumberOfRecordsForFileWithUpdatedLayout(
            ConvertToClaimRulesCommand sut
        )
        {
            sut.RoleAssignmentFile = ConvertToClaimRulesCommandTest.updatedLayoutFile;
            sut.PermissionsUriPrefix = "http://schemas.danskeregioner.dk/2013/10/identity/claims/rettighed/";
            sut.PermissionIdsStartCell = new GridCoordinate(5, 0);
            sut.PermissionsShortNameColumnIndex = 1;
            sut.PermissionsTitleColumnIndex = 2;
            sut.RoleValuesStartCell = new GridCoordinate(2, 10);

            Assert.Equal(18, sut.Invoke().OfType<RolePermissionClaimRule>().Count());
        }
        public void InvokeReturnsCorrectNumberOfRecordsForAllAssignmentsFile(
            ConvertToClaimRulesCommand sut
        )
        {
            sut.RoleAssignmentFile = ConvertToClaimRulesCommandTest.allPermissionsAssignmentsFile;
            sut.PermissionsUriPrefix = "http://schemas.danskeregioner.dk/2013/10/identity/claims/rettighed/";

            Assert.Equal(315, sut.Invoke().OfType<RolePermissionClaimRule>().Count());
        }