|
//-----------------------------------------------------------------------
// <copyright>
// Copyright (c) TommySoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System.Windows;
using NUnit.Framework;
using System.Windows.Media;
using System.Windows.Threading;
using System;
using System.Threading;
namespace TSoftControlLibrary
{
[TestFixture]
public class RotateControlTest
{
/// <summary>
/// Test that the angle is coerced to a value between 0 and 360 no matter what it is set to
/// </summary>
[Test]
public void AngleIsBetweenZeroAnd360()
{
RotateControl control = new RotateControl();
control.Angle = 180;
Assert.AreEqual(180, control.Angle);
control.Angle = 359;
Assert.AreEqual(359, control.Angle);
control.Angle = 360;
Assert.AreEqual(0, control.Angle);
control.Angle = -1;
Assert.AreEqual(359, control.Angle);
control.Angle = -180;
Assert.AreEqual(180, control.Angle);
control.Angle = -360;
Assert.AreEqual(0, control.Angle);
control.Angle = -361;
Assert.AreEqual(359, control.Angle);
control.Angle = 720;
Assert.AreEqual(0, control.Angle);
control.Angle = 721;
Assert.AreEqual(1, control.Angle);
}
[Test]
public void ShowInWindow()
{
Window w = new Window();
w.Content = new RotateControl() { Width=200, Height=200, BorderBrush=Brushes.Blue, BorderThickness=new Thickness(1)};
w.ShowDialog();
}
[Test]
public void ShowAndRotate()
{
Window w = new Window();
var ctrl = new RotateControl() { Width = 200, Height = 200, BorderBrush = Brushes.Blue, BorderThickness = new Thickness(1) };
w.Content = ctrl;
DispatcherTimer timer = new DispatcherTimer(){ Interval = TimeSpan.FromMilliseconds(50)};
timer.Tick += delegate {
ctrl.Angle += 10;
};
timer.Start();
w.ShowDialog();
}
[Test]
public void ShowRotateControlTestWindow1()
{
RotateControlTestWindow1 w = new RotateControlTestWindow1();
w.ShowDialog();
}
[Test]
public void ShowRotateUserControlTestWindow1()
{
RotateUserControlTestWindow1 w = new RotateUserControlTestWindow1();
w.ShowDialog();
}
[Test]
public void ShowUserControlInWindow()
{
Window w = new Window();
w.Content = new RotateUserControl() { Width = 200, Height = 200, BorderBrush = Brushes.Blue, BorderThickness = new Thickness(1) };
w.ShowDialog();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.