Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulino committed Aug 18, 2021
1 parent 36f46be commit f458d51
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions UnitTests/UnitTests.UWP/UI/Triggers/Test_ControlSizeTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,74 @@ await App.DispatcherQueue.EnqueueAsync(() =>
});
}

[DataTestMethod]
[DataRow(400, 400, true)]
[DataRow(400, 399, false)]
public async Task ControlSizeMinHeightTriggerTest(double width, double height, bool expectedResult)
{
await App.DispatcherQueue.EnqueueAsync(() =>
{
Grid grid = CreateGrid(width, height);
var trigger = new ControlSizeTrigger();

trigger.TargetElement = grid;
trigger.MinHeight = 400;

Assert.AreEqual(expectedResult, trigger.IsActive);
});
}

[DataTestMethod]
[DataRow(399, 400, false)]
[DataRow(400, 400, true)]
public async Task ControlSizeMinWidthTriggerTest(double width, double height, bool expectedResult)
{
await App.DispatcherQueue.EnqueueAsync(() =>
{
Grid grid = CreateGrid(width, height);
var trigger = new ControlSizeTrigger();

trigger.TargetElement = grid;
trigger.MinWidth = 400;

Assert.AreEqual(expectedResult, trigger.IsActive);
});
}

[DataTestMethod]
[DataRow(450, 450, false)]
[DataRow(450, 449, true)]
public async Task ControlSizeMaxHeightTriggerTest(double width, double height, bool expectedResult)
{
await App.DispatcherQueue.EnqueueAsync(() =>
{
Grid grid = CreateGrid(width, height);
var trigger = new ControlSizeTrigger();

trigger.TargetElement = grid;
trigger.MaxHeight = 450;

Assert.AreEqual(expectedResult, trigger.IsActive);
});
}

[DataTestMethod]
[DataRow(450, 450, false)]
[DataRow(449, 450, true)]
public async Task ControlSizeMaxWidthTriggerTest(double width, double height, bool expectedResult)
{
await App.DispatcherQueue.EnqueueAsync(() =>
{
Grid grid = CreateGrid(width, height);
var trigger = new ControlSizeTrigger();

trigger.TargetElement = grid;
trigger.MaxWidth = 450;

Assert.AreEqual(expectedResult, trigger.IsActive);
});
}

private Grid CreateGrid(double width, double height)
{
var grid = new Grid()
Expand Down

0 comments on commit f458d51

Please sign in to comment.