private void AssertPropertyValue(object beetleObject, string propertyName, object expectedValue) { object actualValue = BeetleHelper.GetPropertyValue(beetleObject, propertyName); Assert.That(actualValue, Is.EqualTo(expectedValue), $"Beetle property {propertyName} has value ({actualValue}) but expected ({expectedValue})"); }
public void _15_ShouldNotMoveWhenSpeedIsZero() { _beetleSpeed = 0; BeetleHelper.SetSpeedPropertyValue(_beetleObject, _beetleSpeed); AssertAndInvokeChangePositionMethod(_beetleObject); AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX); // should not move AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY); // should not move }
public void _14_ShouldBecomeInvisibleWhenPropertyIsSet() { BeetleHelper.SetIsVisibleProperty(_beetleObject, true); Assert.That(_beetleEllipse.Visibility, Is.EqualTo(Visibility.Visible), "Setting IsVisible on Beetle to true should make the ellipse visible"); BeetleHelper.SetIsVisibleProperty(_beetleObject, false); Assert.That(_beetleEllipse.Visibility, Is.EqualTo(Visibility.Hidden), "Setting IsVisible on Beetle to false should hide the ellipse"); }
public void _09_ShouldMoveDownAndRightWithoutHittingBorder() { BeetleHelper.SetRightProperty(_beetleObject, true); BeetleHelper.SetUpProperty(_beetleObject, false); AssertAndInvokeChangePositionMethod(_beetleObject); // verify the beetle went in up and right direction AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX + 1); AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY + 1); AssertEllipsePosition(_beetleX + 1, _beetleY + 1); }
public void _13_ShouldTurnRightWhenHittingLeftSideOfCanvas() { _beetleX = (_beetleSize / 2) + 1; // 1 pixel from left side BeetleHelper.SetXProperty(_beetleObject, _beetleX); BeetleHelper.SetRightProperty(_beetleObject, false); BeetleHelper.SetUpProperty(_beetleObject, false); AssertAndInvokeChangePositionMethod(_beetleObject); AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX - 1); // should go left AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY + 1); // should go down AssertPropertyValue(_beetleObject, BeetleHelper.RightProperty, true); AssertPropertyValue(_beetleObject, BeetleHelper.UpProperty, false); }
public void _12_ShouldTurnLeftWhenHittingRightSideOfCanvas() { _beetleX = TestCanvasWidth - (_beetleSize / 2) - 1; // 1 pixel from right side BeetleHelper.SetXProperty(_beetleObject, _beetleX); BeetleHelper.SetRightProperty(_beetleObject, true); BeetleHelper.SetUpProperty(_beetleObject, false); AssertAndInvokeChangePositionMethod(_beetleObject); AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX + 1); // should go right AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY + 1); // should go down AssertPropertyValue(_beetleObject, BeetleHelper.RightProperty, false); AssertPropertyValue(_beetleObject, BeetleHelper.UpProperty, false); }
public void _11_ShouldTurnUpWhenHittingLowerBoundOfCanvas() { _beetleY = TestCanvasHeight - (_beetleSize / 2) - 1; // 1 pixel from bottom of canvas BeetleHelper.SetYProperty(_beetleObject, _beetleY); BeetleHelper.SetRightProperty(_beetleObject, true); BeetleHelper.SetUpProperty(_beetleObject, false); AssertAndInvokeChangePositionMethod(_beetleObject); AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX + 1); // should go right AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY + 1); // should go down AssertPropertyValue(_beetleObject, BeetleHelper.UpProperty, true); // should turn AssertPropertyValue(_beetleObject, BeetleHelper.RightProperty, true); }
public void _10_ShouldTurnDownWhenHittingUpperBoundOfCanvas() { _beetleY = _beetleSize / 2 + 1; // 1 pixel from top of canvas BeetleHelper.SetYProperty(_beetleObject, _beetleY); BeetleHelper.SetRightProperty(_beetleObject, true); BeetleHelper.SetUpProperty(_beetleObject, true); AssertAndInvokeChangePositionMethod(_beetleObject); AssertPropertyValue(_beetleObject, BeetleHelper.XProperty, _beetleX + 1); // should go right AssertPropertyValue(_beetleObject, BeetleHelper.YProperty, _beetleY - 1); // should go up AssertPropertyValue(_beetleObject, BeetleHelper.UpProperty, false); // should turn AssertPropertyValue(_beetleObject, BeetleHelper.RightProperty, true); }
public void _M18_ShouldChangeTimerIntervalSpeedPropertyAndLabelWhenChangingSliderValue() { AssertHasDispatcherTimer(); AssertDispatcherTimerIntervalWithRespectToBeetleSizeAndSpeed(); Assert.That(BeetleHelper.GetSpeedProperty(_beetleObject), Is.EqualTo(_speedSlider.Value), $"Beetle object speed expected to be the same as slider value ({_speedSlider.Value}) but was ({BeetleHelper.GetSpeedProperty(_beetleObject)})"); _speedSlider.Value = 5.5; AssertDispatcherTimerIntervalWithRespectToBeetleSizeAndSpeed(); Assert.That(BeetleHelper.GetSpeedProperty(_beetleObject), Is.EqualTo(_speedSlider.Value), $"Beetle object size expected to be the same as slider value ({_speedSlider.Value}) but was ({BeetleHelper.GetSpeedProperty(_beetleObject)})"); Assert.That(Convert.ToDouble(_speedLabel.Content), Is.EqualTo(_speedSlider.Value), $"Label for speed expected to be the same as slider value ({_speedSlider.Value}) but was ({_speedLabel.Content})"); }
public void _M15_ShouldResetTheScreenWhenHittingResetButton() { _resetButton.FireClickEvent(); Assert.That(_speedSlider.Value, Is.EqualTo(_speedSlider.Minimum), "Hitting the <Reset> button should set the speed slider value to its minimum"); Assert.That(_sizeSlider.Value, Is.EqualTo(_sizeSlider.Minimum), "Hitting the <Reset> button should set the size slider value to its minimum"); Assert.That(_speedSlider.IsEnabled, Is.True, "Hitting the <Reset> button should set the enable the speed slider"); Assert.That(_sizeSlider.IsEnabled, Is.True, "Hitting the <Reset> button should set the enable the size slider"); Assert.That(_startButton.Content, Is.EqualTo("Start"), "Hitting the <Reset> button should set the <Start> button content to Start"); Assert.That(BeetleHelper.GetIsVisibleProperty(_beetleObject), Is.False, "Hitting the <Reset> button should set the IsVisible property of the beetle to false"); Assert.That(_dispatcherTimer.IsEnabled, Is.False, "Hitting the <Reset> button should disable the timer"); }
public void Setup() { _testCanvas = new Canvas { Width = TestCanvasWidth, Height = TestCanvasHeight }; _beetleSize = 10; _beetleX = 40; _beetleY = 35; _beetleSpeed = 0.5; _beetleObject = BeetleHelper.CreateBeetle(_testCanvas, _beetleX, _beetleY, _beetleSize); if (_beetleObject != null) { BeetleHelper.SetSpeedPropertyValue(_beetleObject, _beetleSpeed); } _beetleEllipse = (_testCanvas.Children.Count > 0 ? _testCanvas.Children[0] as Ellipse : null); }
public void _M14_ShouldSetBeetleUpPropertyToFalseWhenHittingDownButton() { _downButton.FireClickEvent(); Assert.That(BeetleHelper.GetUpProperty(_beetleObject), Is.False, "Hitting the <Down> button should change Up property on Beetle to false"); }
public void _M14_ShouldSetBeetleUpPropertyToTrueWhenHittingUpButton() { _upButton.FireClickEvent(); Assert.That(BeetleHelper.GetUpProperty(_beetleObject), Is.True, "Hitting the <Up> button should change Up property on Beetle to true"); }
public void _M12_ShouldSetBeetleRightPropertyToTrueWhenHittingRightButton() { _rightButton.FireClickEvent(); Assert.That(BeetleHelper.GetRightProperty(_beetleObject), Is.True, "Hitting the <Right> button should change Right property on Beetle to true"); }
public void _M11_ShouldSetBeetleRightPropertyToFalseWhenHittingLeftButton() { _leftButton.FireClickEvent(); Assert.That(BeetleHelper.GetRightProperty(_beetleObject), Is.False, "Hitting the <Left> button should change Right property on Beetle to false"); }