Beispiel #1
0
        public void TestGetResourceId_DictionaryKeyNotPresnt_NoKeysInDictionary()
        {
            var dictionary     = new Dictionary <string, object>();
            var resourceType   = "project";
            var permissionName = "edit";
            var permission     = new ModelPermission("B.OtherId", typeof(ABindingModel), permissionName, resourceType);

            permission.Invoking(x => x.GetResourceId(dictionary)).ShouldThrow <NotSupportedException>()
            .WithMessage("There are no action arguments to check permissions with.  There must be at least one action argument.");
        }
Beispiel #2
0
        public void TestGetResourceId_PropertyDoesNotExist()
        {
            var resourceType   = "project";
            var permissionName = "edit";
            var instance       = new ABindingModel();
            var permission     = new ModelPermission("model.X", typeof(ABindingModel), permissionName, resourceType);
            var dictionary     = GetActionArgumentsDictionary(instance, "model");

            permission.Invoking(y => y.GetResourceId(dictionary)).ShouldThrow <NotSupportedException>()
            .WithMessage(String.Format("The property [{0}] does not exist in the model of type [{1}].", "X", "ABindingModel"));
        }
Beispiel #3
0
        public void TestGetResourceId_PropertyIsNotNumeric()
        {
            var resourceType   = "project";
            var permissionName = "edit";
            var instance       = new ABindingModel();
            var permission     = new ModelPermission("model.S", typeof(ABindingModel), permissionName, resourceType);
            var dictionary     = GetActionArgumentsDictionary(instance, "model");

            permission.Invoking(y => y.GetResourceId(dictionary)).ShouldThrow <NotSupportedException>()
            .WithMessage(String.Format("The nested property [{0}] in the model's property hierarchy [{1}] must be an integer.", "S", "model.S"));
        }
Beispiel #4
0
        public void TestGetResourceId_DictionaryKeyNotPresnt_TwoKeysInDictionary()
        {
            var dictionary = new Dictionary <string, object>();

            dictionary.Add("key1", 1);
            dictionary.Add("key2", 2);
            var resourceType   = "project";
            var permissionName = "edit";
            var permission     = new ModelPermission("B.OtherId", typeof(ABindingModel), permissionName, resourceType);

            permission.Invoking(x => x.GetResourceId(dictionary)).ShouldThrow <NotSupportedException>()
            .WithMessage("There are more than one action arguments for the web api.  You must specify the name of the variable in the property path.");
        }