示例#1
0
        public void Constructor_WithCanExecuteParameter_CanExecuteIsNotNull()
        {
            ObservableVariable <bool> canExecute = new ObservableVariable <bool>();

            ObservableCommand command = new ObservableCommand(canExecute);

            Assert.IsNotNull(command.CanExecute);
        }
示例#2
0
        public void Constructor_WithCanExecuteParameter_CanExecuteValueIsTrue()
        {
            ObservableVariable <bool> canExecute = new ObservableVariable <bool>(true);

            ObservableCommand command = new ObservableCommand(canExecute);

            Assert.IsTrue(command.CanExecute.Value);
        }
示例#3
0
		public IEnumerator Subscribe_WhenSubscription_NoCallbackIsRaised()
		{
			ObservableVariable<int> variable = new ObservableVariable<int>();

			variable.Changed += IncrementCallbackCount;

			Assert.IsTrue(callbackCount == 0);

			yield return null;
		}
示例#4
0
		public IEnumerator Value_WhenSetTheSameValue_DontRaiseCallback()
		{
			ObservableVariable<int> variable = new ObservableVariable<int>();

			variable.Value = 14;

			Assert.IsTrue(variable.Value == 14);

			yield return null;
		}
示例#5
0
		public IEnumerator Value_WhenSetAValue_KeepsThatValue()
		{
			ObservableVariable<int> variable = new ObservableVariable<int>();

			variable.Value = 14;

			Assert.IsTrue(variable.Value == 14);

			yield return null;
		}
示例#6
0
		public IEnumerator Subscribe_WhenValueChange_OnlyOneCallCallbackIsRaised()
		{
			ObservableVariable<int> variable = new ObservableVariable<int>();
			variable.Changed += IncrementCallbackCount;

			variable.Value = 42;

			Assert.IsTrue(callbackCount == 1);

			yield return null;
		}
示例#7
0
		public IEnumerator Subscribe_WhenValueChange_CallCallback()
		{
			ObservableVariable<int> variable = new ObservableVariable<int>();
			variable.Changed += CopyIntVariable;

			variable.Value = 14;

			Assert.IsTrue(intMirrorVariable == 14);

			yield return null;
		}
示例#8
0
        public void Generic_Execute_WhenCanExecute_ParameterIsReceived()
        {
            ObservableVariable <bool> canExecute = new ObservableVariable <bool>(true);
            ObservableCommand <int>   command    = new ObservableCommand <int>(canExecute);
            int mirrorVariable = -1;

            command.ExecuteRequested += (int value) => mirrorVariable = value;

            command.Execute(14);

            Assert.IsTrue(mirrorVariable == 14);
        }
示例#9
0
        public void Execute_WhenCanNotExecute_DoNotRaiseEvent()
        {
            ObservableVariable <bool> canExecute = new ObservableVariable <bool>();
            ObservableCommand         command    = new ObservableCommand(canExecute);

            canExecute.Value = false;
            int callbackCount = 0;

            command.ExecuteRequested += () => callbackCount++;

            command.Execute();

            Assert.IsTrue(callbackCount == 0);
        }
示例#10
0
        public void Generic_Execute_WhenCanNotExecute_DoNotRaiseEvent()
        {
            ObservableVariable <bool> canExecute = new ObservableVariable <bool>(true);
            ObservableCommand <int>   command    = new ObservableCommand <int>(canExecute);

            canExecute.Value = false;
            int callbackCount = 0;

            command.ExecuteRequested += (int value) => callbackCount++;

            command.Execute(14);

            Assert.IsTrue(callbackCount == 0);
        }