This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathDefinitionCollectionTests.xaml.cs
50 lines (43 loc) · 1.88 KB
/
DefinitionCollectionTests.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Xamarin.Forms;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
public partial class DefinitionCollectionTests : ContentPage
{
public DefinitionCollectionTests() => InitializeComponent();
public DefinitionCollectionTests(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
[TestFixture]
class Tests
{
[SetUp] public void Setup() => Device.PlatformServices = new MockPlatformServices();
[TearDown] public void TearDown() => Device.PlatformServices = null;
[Test]
public void DefinitionCollectionsParsedFromMarkup([Values(false, true)] bool useCompiledXaml)
{
var layout = new DefinitionCollectionTests(useCompiledXaml);
var coldef = layout.grid.ColumnDefinitions;
var rowdef = layout.grid.RowDefinitions;
Assert.That(coldef.Count, Is.EqualTo(5));
Assert.That(coldef[0].Width, Is.EqualTo(new GridLength(1, GridUnitType.Star)));
Assert.That(coldef[1].Width, Is.EqualTo(new GridLength(2, GridUnitType.Star)));
Assert.That(coldef[2].Width, Is.EqualTo(new GridLength(1, GridUnitType.Auto)));
Assert.That(coldef[3].Width, Is.EqualTo(new GridLength(1, GridUnitType.Star)));
Assert.That(coldef[4].Width, Is.EqualTo(new GridLength(300, GridUnitType.Absolute)));
Assert.That(rowdef.Count, Is.EqualTo(5));
Assert.That(rowdef[0].Height, Is.EqualTo(new GridLength(1, GridUnitType.Star)));
Assert.That(rowdef[1].Height, Is.EqualTo(new GridLength(1, GridUnitType.Auto)));
Assert.That(rowdef[2].Height, Is.EqualTo(new GridLength(25, GridUnitType.Absolute)));
Assert.That(rowdef[3].Height, Is.EqualTo(new GridLength(14, GridUnitType.Absolute)));
Assert.That(rowdef[4].Height, Is.EqualTo(new GridLength(20, GridUnitType.Absolute)));
}
}
}
}