public void Invoke_IncrementWithDuration_ThrowsInvalidOperationException() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Opacity", 0.5d); action.Increment = true; action.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(1)); AttachAction(host, trigger, action); trigger.FireStubTrigger(); }
public void Invoke_AnimateChangeOnNonDependencyProperty_ThrowsInvalidOperationException() { Button button = CreateButton(); ChangePropertyActionTargetStub stubTarget = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.DoublePropertyName, 10); AttachAction(button, trigger, action); action.Duration = TimeSpan.FromMilliseconds(10); action.TargetObject = stubTarget; trigger.FireStubTrigger(); }
public void Invoke_IncrementWriteOnlyProperty_ThrowsInvalidOperationException() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.WriteOnlyPropertyName, null); action.TargetObject = target; AttachAction(host, trigger, action); action.Increment = true; trigger.FireStubTrigger(); }
public void Invoke_TargetObjectValueConflictingTypeProperty_AssignBoolToString() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.StringPropertyName, true); AttachAction(host, trigger, action); action.TargetObject = target; trigger.FireStubTrigger(); Assert.AreEqual(target.StringProperty, "True", "StringProperty should have been assigned True as a string"); }
public void Invoke_IncrementWithAmbiguousAdditionOverride_ThrowsArgumentException() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, "#FF00FF00"); target.ObjectProperty = CreateAdditiveObject(); action.TargetObject = target; action.Increment = true; AttachAction(host, trigger, action); trigger.FireStubTrigger(); }
// todo: might already have this one public void Invoke_ValueIsChanged_NewValueIsSet() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, 10.0d); action.TargetObject = target; AttachAction(host, trigger, action); action.Value = host; trigger.FireStubTrigger(); Assert.AreEqual(target.ObjectProperty, host, "target.DoubleProperty should be host after Invoke"); }
// todo: might already have this one public void Invoke_PropertyIsChanged_OldPropertyIsNotSet() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, 10.0d); action.TargetObject = target; AttachAction(host, trigger, action); action.PropertyName = "DoubleProperty"; trigger.FireStubTrigger(); Assert.IsNull(target.ObjectProperty, "target.DoubleProperty should be null after Invoke"); }
public void Invoke_TargetObjectReferenceTypeProperty_SetsProperty() { Button value = CreateButton(); Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, value); action.TargetObject = target; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.AreEqual(target.ObjectProperty, value, "target.ObjectProperty should point to the Button after Invoke"); }
public void Invoke_TargetObjectValueTypeProperty_SetsProperty() { double value = 10.0d; Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.DoublePropertyName, value); action.TargetObject = target; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.AreEqual(target.DoubleProperty, value, "target.DoubleProperty should be 10 after Invoke"); }
public void Invoke_IncrementStringProperty_AppendsStringValue() { ChangePropertyActionTargetStub target = CreateTargetStub(); Button host = CreateButton(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.StringPropertyName, " World!"); target.StringProperty = "Hello"; action.TargetObject = target; action.Increment = true; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.AreEqual(target.StringProperty, "Hello World!", "StringProperty should have been appended with 'World!', resulting in 'Hello World!'"); }
public void Invoke_IncrementDoubleProperty_IncrementsProperty() { ChangePropertyActionTargetStub target = CreateTargetStub(); Button host = CreateButton(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.DoublePropertyName, 10.5d); target.DoubleProperty = 10.0d; action.TargetObject = target; action.Increment = true; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.AreEqual(target.DoubleProperty, 20.5d, "DoubleProperty should have been incremented by 10.5 to a total of 20.5"); }
public void Invoke_IncrementByNull_SetsNullInstead() { ChangePropertyActionTargetStub target = CreateTargetStub(); Button host = CreateButton(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, null); AttachAction(host, trigger, action); action.TargetObject = target; action.Increment = true; target.ObjectProperty = "not null"; trigger.FireStubTrigger(); Assert.IsNull(target.ObjectProperty, "Target.ObjectProperty should have been set to null, ignoring the increment."); }
public void Invoke_IncrementWithMultipleAdditionOverrides_CallsCorrectOverride() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, 0.5d); target.ObjectProperty = CreateAdditiveObject(); action.TargetObject = target; action.Increment = true; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.AreEqual(((AdditiveObjectStub)target.ObjectProperty).AddType, "double", "Double addition override should have been called."); }
public void Invoke_IncrementOpAdditionOverrideType_CallsOpAdditionOverride() { ChangePropertyActionTargetStub target = CreateTargetStub(); Button host = CreateButton(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.ObjectPropertyName, CreateAdditiveObject()); AdditiveObjectStub addObject = CreateAdditiveObject(); target.ObjectProperty = addObject; action.TargetObject = target; action.Increment = true; AttachAction(host, trigger, action); trigger.FireStubTrigger(); Assert.IsTrue(((AdditiveObjectStub)target.ObjectProperty).Added, "AddObject.op_Addition should have been called."); }
public void Invoke_IncrementIsSetToTrue_IncrementBehaviorIsInvoked() { Button host = CreateButton(); ChangePropertyActionTargetStub target = CreateTargetStub(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(ChangePropertyActionTargetStub.DoublePropertyName, 10.0d); // setting to 5 so we have an assurance that we didn't just increment twice target.DoubleProperty = 5.0d; action.TargetObject = target; AttachAction(host, trigger, action); trigger.FireStubTrigger(); action.Increment = true; trigger.FireStubTrigger(); Assert.AreEqual(target.DoubleProperty, 20.0d, "target.DoubleProperty should be 20 after Invoke, then incremental Invoke"); }