public void CommonPermission_PermissionCalculate_Test()
        {
            //初始化
            Role role = new Role();
            AccessObject accessObject = AccessObjectFactory.CreateAcessObject(1, false);
            CommonPermissionConfig config = new CommonPermissionConfig(role, accessObject);
            var operation = accessObject.Operations.First();
            config.SetOperationPermission(operation, true, false);

            CommonPermission commonPermission = new CommonPermission(accessObject);

            //操作
            commonPermission.PermissionCalculate(config);

            //验证
            Assert.AreSame(config, commonPermission.PermissionConfigs.First());
            Assert.IsTrue(commonPermission.HavePermission(operation));
            Assert.IsFalse(commonPermission.HavePermission(
                accessObject.Operations.First(o => o != operation)));
        }
        public void CommonPermission_Constructor_With_PermissionConfigs_Test()
        {
            //初始化
            Role role = new Role();
            AccessObject accessObject = AccessObjectFactory.CreateAcessObject(1, false);
            CommonPermissionConfig config = new CommonPermissionConfig(role, accessObject);

            var operation = accessObject.Operations.First();
            config.SetOperationPermission(operation, true, false);

            CommonPermission commonPermission = new CommonPermission(
                accessObject,
                new CommonPermissionConfig[] { config });

            //验证
            Assert.AreEqual(accessObject.Operations.Count(), commonPermission.OperationPermissions.Count());
            Assert.AreSame(config, commonPermission.PermissionConfigs.First());
            Assert.IsTrue(commonPermission.HavePermission(operation));
            Assert.IsFalse(commonPermission.HavePermission(
                accessObject.Operations.First(o => o != operation)));
        }
        public void CommonPermission_PermissionCalculate_InvalidConfigAccessObject_Test()
        {
            //初始化
            Role role = new Role();
            AccessObject accessObject = AccessObjectFactory.CreateAcessObject(1, false);
            CommonPermissionConfig config = new CommonPermissionConfig(role, accessObject);
            var operation = accessObject.Operations.First();
            config.SetOperationPermission(operation, true, false);

            CommonPermission commonPermission = new CommonPermission(accessObject);

            //操作
            commonPermission.PermissionCalculate(new CommonPermissionConfig());
        }