Exemple #1
0
        public void when_can_execute_property_path_changes_then_raises_can_execute_changed()
        {
            var target  = JObject.Parse(@"
{ 
	""Connection"": {
		""Status"": {
			""IsEnabled"": true
		}
	}
}");
            var command = new JsonCommand(
                JObject.Parse(@"{ ""$CanExecute"": ""Connection.Status.IsEnabled"", ""Name"": ""kzu""  }"),
                target);

            var changed = false;

            command.CanExecuteChanged += (_, __) => changed = true;

            target.Property("Connection").Value.Value <JObject> ()
            .Property("Status").Value.Value <JObject> ()
            .Property("IsEnabled").Value = false;

            Assert.False(command.CanExecute(null));
            Assert.True(changed);
        }
Exemple #2
0
        public void when_can_execute_is_property_name_then_retrieves_value_from_target()
        {
            var command = new JsonCommand(
                JObject.Parse(@"{ ""$CanExecute"": ""IsEnabled"", ""Name"": ""kzu""  }"),
                JObject.Parse(@"{ ""IsEnabled"": true  }"));

            Assert.True(command.CanExecute(null));
        }
Exemple #3
0
        public void when_no_can_execute_exists_then_can_execute_true()
        {
            var command = new JsonCommand(
                JObject.Parse(@"{ ""Name"": ""kzu""  }"),
                JObject.Parse(@"{ ""Name"": ""vga""  }"));

            Assert.True(command.CanExecute(null));
        }
Exemple #4
0
        public void when_can_execute_is_property_name_then_retrieves_value_from_target()
        {
            var command = new JsonCommand (
                JObject.Parse (@"{ ""$CanExecute"": ""IsEnabled"", ""Name"": ""kzu""  }"),
                JObject.Parse (@"{ ""IsEnabled"": true  }"));

            Assert.True (command.CanExecute (null));
        }
Exemple #5
0
        public void when_can_execute_changes_then_raises_can_execute_changed()
        {
            var json = JObject.Parse (@"{ ""$CanExecute"": false, ""Name"": ""kzu""  }");
            var command = new JsonCommand (json,
                JObject.Parse (@"{ ""Name"": ""vga""  }"));

            var changed = false;
            command.CanExecuteChanged += (_, __) => changed = true;

            Assert.False (json.Property ("$CanExecute").Value.Value<bool> ());
            Assert.False (command.CanExecute (null));

            json.Property ("$CanExecute").Value = true;

            Assert.True (command.CanExecute (null));
            Assert.True (changed);
        }
Exemple #6
0
        public void when_can_execute_changes_then_raises_can_execute_changed()
        {
            var json    = JObject.Parse(@"{ ""$CanExecute"": false, ""Name"": ""kzu""  }");
            var command = new JsonCommand(json,
                                          JObject.Parse(@"{ ""Name"": ""vga""  }"));

            var changed = false;

            command.CanExecuteChanged += (_, __) => changed = true;

            Assert.False(json.Property("$CanExecute").Value.Value <bool> ());
            Assert.False(command.CanExecute(null));

            json.Property("$CanExecute").Value = true;

            Assert.True(command.CanExecute(null));
            Assert.True(changed);
        }
Exemple #7
0
        public void when_no_can_execute_exists_then_can_execute_true()
        {
            var command = new JsonCommand (
                JObject.Parse (@"{ ""Name"": ""kzu""  }"),
                JObject.Parse (@"{ ""Name"": ""vga""  }"));

            Assert.True (command.CanExecute (null));
        }
Exemple #8
0
        public void when_can_execute_property_path_changes_then_raises_can_execute_changed()
        {
            var target = JObject.Parse (@"
            {
            ""Connection"": {
            ""Status"": {
            ""IsEnabled"": true
            }
            }
            }");
            var command = new JsonCommand (
                JObject.Parse (@"{ ""$CanExecute"": ""Connection.Status.IsEnabled"", ""Name"": ""kzu""  }"),
                target);

            var changed = false;
            command.CanExecuteChanged += (_, __) => changed = true;

            target.Property ("Connection").Value.Value<JObject> ()
                .Property ("Status").Value.Value<JObject> ()
                .Property ("IsEnabled").Value = false;

            Assert.False (command.CanExecute (null));
            Assert.True (changed);
        }