public void Invoke_ChangePropertyFromFillToStroke_ChangesAppropriateProperty() { Rectangle rectangle = CreateRectangle(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Fill", Brushes.Green); AttachAction(rectangle, trigger, action); trigger.FireStubTrigger(); action.PropertyName = "Stroke"; trigger.FireStubTrigger(); Assert.AreEqual(rectangle.Stroke, Brushes.Green, "rectangle.Stroke == Green"); }
public void Invoke_ChangeValueFromGreenToYellow_ChangesToAppropriateValue() { Rectangle rectangle = CreateRectangle(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Fill", Brushes.Green); AttachAction(rectangle, trigger, action); trigger.FireStubTrigger(); action.Value = Brushes.Yellow; trigger.FireStubTrigger(); Assert.AreEqual(rectangle.Fill, Brushes.Yellow, "rectangle.Fill == Yellow"); }
public void RemoveFromDecoratorTest() { Rectangle rectangle = new Rectangle(); StubTrigger trigger = SetupRemoveAction(rectangle); Decorator decorator = new Decorator(); decorator.Child = rectangle; trigger.FireStubTrigger(); Assert.IsNull(rectangle.Parent, "rectangle has no parent"); Assert.IsNull(decorator.Child, "page has no content"); // A second removal should not throw an exception. trigger.FireStubTrigger(); }
public void RemoveFromPageTest() { Rectangle rectangle = new Rectangle(); StubTrigger trigger = SetupRemoveAction(rectangle); Page page = new Page(); page.Content = rectangle; trigger.FireStubTrigger(); Assert.IsNull(rectangle.Parent, "rectangle has no parent"); Assert.IsNull(page.Content, "page has no content"); // A second removal should not throw an exception. trigger.FireStubTrigger(); }
public void RemoveFromContentControlTest() { Rectangle rectangle = new Rectangle(); StubTrigger trigger = SetupRemoveAction(rectangle); ContentControl contentControl = new ContentControl(); contentControl.Content = rectangle; trigger.FireStubTrigger(); Assert.IsNull(rectangle.Parent, "rectangle has no parent"); Assert.IsNull(contentControl.Content, "contentControl has no content"); // A second removal should not throw an exception. trigger.FireStubTrigger(); }
public void Invoke_NotAttached_IsNoOp() { StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Foo", Brushes.Green); trigger.FireStubTrigger(); }
public void RemoveFromPanelTest() { // Panel test Rectangle rectangle = new Rectangle(); Canvas canvas = new Canvas(); canvas.Children.Add(rectangle); StubTrigger trigger = SetupRemoveAction(rectangle); trigger.FireStubTrigger(); Assert.IsNull(rectangle.Parent, "rectangle has no parent"); Assert.AreEqual(canvas.Children.Count, 0, "canvas has no children"); // A second removal should not thrown an exception. trigger.FireStubTrigger(); }
public void InvokeTriggerWithConditionalBehavior_TwoConditionsOneNotMet() { ConditionalExpression conditionalExpression = null; StubTrigger trigger = null; StubAction action = null; SetupTriggerActionConditionBehavior(out conditionalExpression, out trigger, out action); // Resetting an non met condition conditionalExpression.Conditions.Add(new ComparisonCondition()); conditionalExpression.Conditions[0].LeftOperand = BehaviorTestUtilities.IntegerOperand4; conditionalExpression.Conditions[0].RightOperand = BehaviorTestUtilities.IntegerOperand5; conditionalExpression.Conditions[0].Operator = ComparisonConditionType.GreaterThan; // Add the second condition conditionalExpression.Conditions.Add(new ComparisonCondition()); Assert.IsTrue(conditionalExpression.Conditions.Count == 2, "We should have 2 conditions"); // Creating a new condition conditionalExpression.Conditions[1].LeftOperand = BehaviorTestUtilities.IntegerOperand5; conditionalExpression.Conditions[1].RightOperand = BehaviorTestUtilities.IntegerOperand6; conditionalExpression.Conditions[1].Operator = ComparisonConditionType.LessThan; // Firing the trigger, with one of the condition not met trigger.FireStubTrigger(); Assert.AreEqual(action.InvokeCount, 0, "action.InvokeCount == 0, one conditon not met"); }
public void InvokeTriggerWithConditionalBehavior_TwoConditionsBothNotMetForwardChainingOr() { ConditionalExpression conditionalExpression = null; StubTrigger trigger = null; StubAction action = null; SetupTriggerActionConditionBehavior(out conditionalExpression, out trigger, out action); // Resetting an non met condition conditionalExpression.Conditions.Add(new ComparisonCondition()); conditionalExpression.Conditions[0].LeftOperand = BehaviorTestUtilities.IntegerOperand4; conditionalExpression.Conditions[0].RightOperand = BehaviorTestUtilities.IntegerOperand5; conditionalExpression.Conditions[0].Operator = ComparisonConditionType.GreaterThan; // Add the second condition conditionalExpression.Conditions.Add(new ComparisonCondition()); Assert.IsTrue(conditionalExpression.Conditions.Count == 2, "We should have 2 conditions"); // Creating a new condition conditionalExpression.Conditions[1].LeftOperand = BehaviorTestUtilities.IntegerOperand5; conditionalExpression.Conditions[1].RightOperand = BehaviorTestUtilities.IntegerOperand6; conditionalExpression.Conditions[1].Operator = ComparisonConditionType.GreaterThan; // Firing the trigger, forward chaining changed to OR. conditionalExpression.ForwardChaining = ForwardChaining.Or; trigger.FireStubTrigger(); Assert.AreEqual(action.InvokeCount, 0, "action.InvokeCount == 0, both conditons are not met, forward chaining was Or"); }
public void InvokeTest() { StubAction action = new StubAction(); StubTrigger trigger = new StubTrigger(); Assert.AreEqual(action.InvokeCount, 0, "action.InvokeCount == 0"); action.StubInvoke(); Assert.AreEqual(action.InvokeCount, 1, "After invoking action, action.InvokeCount == 1"); trigger.Actions.Add(action); action.IsEnabled = false; trigger.FireStubTrigger(); Assert.AreEqual(action.InvokeCount, 1, "action.InvokeCount == 1"); action.IsEnabled = true; trigger.FireStubTrigger(); Assert.AreEqual(action.InvokeCount, 2, "action.InvokeCount == 2"); }
public void Invoke_IncorrectParametersWithTargetSet_DoesNothing() { MethodObjectStub host = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("IncompatibleParameters"); StubTrigger trigger = AttachAction(action, host); trigger.FireStubTrigger(); Assert.AreEqual(host.LastMethodCalled, "None", "No method should be called"); }
public void Invoke_NonExistantMethodWithNoTarget_DoesNothing() { MethodObjectStub host = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("NonExistantMethodName"); StubTrigger trigger = AttachAction(action, host); trigger.FireStubTrigger(); Assert.AreEqual(host.LastMethodCalled, "None", "No method should be called"); }
public void Invoke_LegalCommandName_InvokesCommand() { InvokeCommandAction invokeCommandAction = CreateInvokeCommandActionWithCommandName("StubCommand"); StubBehavior stubBehavior = CreateStubBehavior(); StubTrigger trigger = AttachActionToObject(invokeCommandAction, stubBehavior); trigger.FireStubTrigger(); Assert.AreEqual(stubBehavior.ExecutionCount, 1, "stubBehavior.ExecutionCount == 1"); }
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"); }
public void Invoke_NoPropertyName_IsNoOp() { StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction(null, Brushes.Green); trigger.Actions.Add(action); trigger.FireStubTrigger(); }
public void Invoke_NonExistantMethodWithTargetSet_ThrowsArgumentException() { Rectangle host = CreateRectangle(); MethodObjectStub target = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("NonExistantMethodName"); StubTrigger trigger = AttachAction(action, host); action.TargetObject = target; trigger.FireStubTrigger(); }
public void Invoke_AnimatedObjectChange_Changes() { Ellipse e = new Ellipse(); ChangePropertyAction c = CreateChangePropertyAction("Fill", Brushes.Gray); StubTrigger t = CreateStubTrigger(); AttachAction(e, t, c); c.Duration = TimeSpan.FromMilliseconds(5); t.FireStubTrigger(); }
public void Invoke_AnimatedColorChange_Changes() { SolidColorBrush brush = new SolidColorBrush(Colors.Red); ChangePropertyAction c = CreateChangePropertyAction("Color", Colors.Gray); StubTrigger t = CreateStubTrigger(); AttachAction(brush, t, c); c.Duration = TimeSpan.FromMilliseconds(5); t.FireStubTrigger(); }
public void Invoke_AnimatedPointChange_Changes() { Ellipse e = new Ellipse(); ChangePropertyAction c = CreateChangePropertyAction("RenderTransformOrigin", new System.Windows.Point(0.3, 0.3)); StubTrigger t = CreateStubTrigger(); AttachAction(e, t, c); c.Duration = TimeSpan.FromMilliseconds(5); t.FireStubTrigger(); }
public void Invoke_AnimatedDoubleChange_Changes() { Ellipse e = new Ellipse(); ChangePropertyAction c = CreateChangePropertyAction("Opacity", 0.0d); StubTrigger t = CreateStubTrigger(); AttachAction(e, t, c); c.Duration = TimeSpan.FromMilliseconds(5); t.FireStubTrigger(); }
public void Invoke_WithCommand_InvokesCommand() { CommandHelper commandHelper = CreateCommandHelper(); InvokeCommandAction invokeCommandAction = CreateInvokeCommandActionWithCommand(commandHelper.SuccessCommand); Button button = CreateButton(); StubTrigger trigger = AttachActionToObject(invokeCommandAction, button); trigger.FireStubTrigger(); Assert.IsTrue(commandHelper.Successful, "Command should have been invoked."); }
public void RemoveFromInvalidComponent() { Rectangle rectangle = new Rectangle(); StubTrigger trigger = SetupRemoveAction(rectangle); RichTextBox textBox = new RichTextBox(); textBox.Document.Blocks.Add(new BlockUIContainer(rectangle)); trigger.FireStubTrigger(); }
public void Invoke_ReadOnlyProperty_ThrowsArgumentException() { Button button = CreateButton(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("IsDefaulted", true); AttachAction(button, trigger, action); trigger.FireStubTrigger(); }
public void Invoke_InvalidPropertyFormatString_ThrowsException() { Rectangle rectangle = CreateRectangle(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Width", "0.0.0.0"); AttachAction(rectangle, trigger, action); trigger.FireStubTrigger(); }
public void Invoke_IncompatiblePropertyWithValueType_ThrowsArgumentException() { Rectangle rectangle = CreateRectangle(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Width", Brushes.Green); AttachAction(rectangle, trigger, action); trigger.FireStubTrigger(); }
public void Invoke_InvalidPropertyName_ThrowsArgumentException() { Rectangle rectangle = CreateRectangle(); StubTrigger trigger = CreateStubTrigger(); ChangePropertyAction action = CreateChangePropertyAction("Foo", Brushes.Green); AttachAction(rectangle, trigger, action); trigger.FireStubTrigger(); }
public void Invoke_UniqueMethodWithNoParameters_IsCalled() { MethodObjectStub methodObject = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("UniqueMethodWithNoParameters"); StubTrigger trigger = AttachAction(action, methodObject); trigger.FireStubTrigger(); Assert.AreEqual(methodObject.LastMethodCalled, "UniqueMethodWithNoParameters", "UniqueMethodWithNoParameters was not called."); }
public void Invoke_IncorrectParametersWithTargetSet_ThrowsArgumentException() { Rectangle host = CreateRectangle(); MethodObjectStub target = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("IncompatibleParameters"); StubTrigger trigger = AttachAction(action, host); action.TargetObject = target; trigger.FireStubTrigger(); }
public void Invoke_MultipleMethodsWithSameName_EventHandlerSignatureIsCalled() { MethodObjectStub methodObject = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("DuplicatedMethod"); StubTrigger trigger = AttachAction(action, methodObject); trigger.FireStubTrigger(EventArgs.Empty); Assert.AreEqual(methodObject.LastMethodCalled, "DuplicatedMethodWithEventHandlerSignature", "DuplicatedMethodWithEventHandlerSignature was not called."); }
public void Invoke_MultipleMethodsWithSpecificParameter_MostDerivedSignatureIsCalled() { MethodObjectStub methodObject = CreateMethodObject(); CallMethodAction action = CreateCallMethodAction("DuplicatedMethod"); StubTrigger trigger = AttachAction(action, methodObject); trigger.FireStubTrigger(new StubEventArgs()); Assert.AreEqual(methodObject.LastMethodCalled, "DuplicatedMethodWithStubEventArgsSignature", "DuplicatedMethodWithStubEventArgsSignature was not called."); }