Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for the string to Type conversion #162

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/SourceGenerators/XamlGenerationTests/TypeConvertersControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

namespace XamlGenerationTests
{
public partial class TypeConvertersControl : FrameworkElement
{
public Type TypeProperty { get; set; }

public Uri UriProperty { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/SourceGenerators/XamlGenerationTests/TypeConvertersTests.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<UserControl
x:Class="XamlGenerationTests.TypeConvertersTests"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uConv="using:Uno.UI.Converters"
xmlns:xamlExpanded="using:Windows.Xaml.UI"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:uloc="http://uno.ui/localization/1.0"
xmlns:local="using:XamlGenerationTests"
mc:Ignorable="d uloc android ios xamarin"
d:DesignHeight="300"
d:DesignWidth="400">

<local:TypeConvertersControl
TypeProperty="local:TypeConvertersControl"
UriProperty="https://platform.uno/" />
</UserControl>
1 change: 1 addition & 0 deletions src/Uno.UI.Tests/Uno.UI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<None Remove="XamlReaderTests\When_TextBlock_FontFamily.xamltest" />
<None Remove="XamlReaderTests\When_TextBlock_ImplicitRun.xamltest" />
<None Remove="XamlReaderTests\When_TextBlock_NestedSpan.xamltest" />
<None Remove="XamlReaderTests\When_TypeConverters.xamltest" />
<None Remove="XamlReaderTests\When_UserControl_With_Content.xamltest" />
<None Remove="XamlReaderTests\When_UserControl_With_Grid.xamltest" />
<None Remove="XamlReaderTests\When_VisualStateGroup.xamltest" />
Expand Down
32 changes: 22 additions & 10 deletions src/Uno.UI.Tests/XamlReaderTests/Given_XamlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,27 @@ public void When_NonDependencyProperty_Binding()
Assert.AreEqual("Text", inner.MyBinding.Path.Path);
}

[TestMethod]
public void When_TypeConverters()
{
var s = GetContent(nameof(When_TypeConverters));
var r = Windows.UI.Xaml.Markup.XamlReader.Load(s) as UserControl;

var root = (TypeConvertersControl)r.Content;

Assert.AreEqual(typeof(TypeConvertersControl), root.TypeProperty);
Assert.AreEqual(new Uri("https://platform.uno/"), root.UriProperty);
}

private string GetContent(string testName)
{
var assembly = this.GetType().Assembly;
var name = $"{GetType().Namespace}.{testName}.xamltest";
// "Uno.UI.Tests.XamlReaderTests.BasicReader.xamltest"
using (var stream = assembly.GetManifestResourceStream(name))
{
return stream.ReadToEnd();
}
}
}
{
var assembly = this.GetType().Assembly;
var name = $"{GetType().Namespace}.{testName}.xamltest";
// "Uno.UI.Tests.XamlReaderTests.BasicReader.xamltest"
using (var stream = assembly.GetManifestResourceStream(name))
{
return stream.ReadToEnd();
}
}
}
}
16 changes: 16 additions & 0 deletions src/Uno.UI.Tests/XamlReaderTests/TypeConvertersControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Uno.UI.Tests.XamlReaderTests
{
public class TypeConvertersControl : FrameworkElement
{
public Type TypeProperty { get; set; }

public Uri UriProperty { get; set; }
}
}
14 changes: 14 additions & 0 deletions src/Uno.UI.Tests/XamlReaderTests/When_TypeConverters.xamltest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:local="using:Uno.UI.Tests.XamlReaderTests"
x:Name="testPage"
mc:Ignorable="d">

<local:TypeConvertersControl
TypeProperty="local:TypeConvertersControl"
UriProperty="https://platform.uno/" />
</Page>