Skip to content

Commit 319b735

Browse files
committed
Added unit test for VisualExtensions.Translation property
1 parent 3c3459a commit 319b735

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading.Tasks;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using Microsoft.Toolkit.Uwp;
8+
using Windows.UI.Xaml.Controls;
9+
using Microsoft.Toolkit.Uwp.UI;
10+
using System.Numerics;
11+
12+
namespace UnitTests.UWP.UI
13+
{
14+
[TestClass]
15+
[TestCategory("Test_VisualExtensions")]
16+
public class Test_VisualExtensions : VisualUITestBase
17+
{
18+
[TestMethod]
19+
public async Task SetAndGetTranslation()
20+
{
21+
await App.DispatcherQueue.EnqueueAsync(async () =>
22+
{
23+
var button = new Button();
24+
var grid = new Grid() { Children = { button } };
25+
26+
VisualExtensions.SetTranslation(button, "80, 20, 0");
27+
28+
await SetTestContentAsync(grid);
29+
30+
Assert.AreEqual(button.GetVisual().TransformMatrix.Translation, new Vector3(80, 20, 0));
31+
32+
string translation = VisualExtensions.GetTranslation(button);
33+
34+
Assert.AreEqual(translation, new Vector3(80, 20, 0).ToString());
35+
});
36+
}
37+
}
38+
}

UnitTests/UnitTests.UWP/UnitTests.UWP.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<Compile Include="UI\Controls\Test_UniformGrid_Dimensions.cs" />
212212
<Compile Include="UI\Controls\Test_WrapPanel_Visibility.cs" />
213213
<Compile Include="UI\Controls\Test_WrapPanel_BasicLayout.cs" />
214+
<Compile Include="UI\Extensions\Test_VisualExtensions.cs" />
214215
<Compile Include="UI\Person.cs" />
215216
<Compile Include="UI\Test_AdvancedCollectionView.cs" />
216217
<Compile Include="UnitTestApp.xaml.cs">

0 commit comments

Comments
 (0)