Skip to content

Commit

Permalink
Update to .net maui
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavAntonyuk committed Oct 20, 2021
1 parent 89793cf commit 13604bd
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 127 deletions.
4 changes: 2 additions & 2 deletions TestAssembly/FooExtension.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Xamarin.Forms.Xaml;
using Microsoft.Maui.Controls.Xaml;
using System;

namespace TestAssembly
{
Expand Down
7 changes: 2 additions & 5 deletions TestAssembly/TestAssembly.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>net6.0;</TargetFrameworks>
<UseMaui>true</UseMaui>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1269" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Xamarin.Forms.Mocks.Tests/AnimationTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Mocks.Tests/AppThemeTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using NUnit.Framework;
using Xamarin.Forms;

Expand Down
7 changes: 4 additions & 3 deletions Xamarin.Forms.Mocks.Tests/ApplicationTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Xamarin.Forms.Xaml;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down Expand Up @@ -40,7 +41,7 @@ public void ApplicationFromXaml()
{
Application.Current = new App();

Assert.AreEqual(Application.Current.Resources["White"], Color.White);
Assert.AreEqual(Application.Current.Resources["White"], Colors.White);
}
}
}
7 changes: 3 additions & 4 deletions Xamarin.Forms.Mocks.Tests/DeviceTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
Expand Down Expand Up @@ -31,7 +32,6 @@ public void RuntimePlatformiOS()
MockForms.Init(Device.iOS);

Assert.AreEqual(Device.iOS, Device.RuntimePlatform);
Assert.AreEqual(TargetPlatform.iOS, Device.OS);
}

[Test]
Expand All @@ -40,7 +40,6 @@ public void RuntimePlatformAndroid()
MockForms.Init(Device.Android);

Assert.AreEqual(Device.Android, Device.RuntimePlatform);
Assert.AreEqual(TargetPlatform.Android, Device.OS);
}

[Test]
Expand Down Expand Up @@ -99,7 +98,7 @@ public void OpenUri()

var expectedUri = new Uri("https://www.google.com");

Device.OpenUri(expectedUri);
Microsoft.Maui.Essentials.Launcher.OpenAsync(expectedUri);

Assert.AreEqual(expectedUri, actual);
Assert.AreEqual(1, callCount);
Expand All @@ -118,7 +117,7 @@ public void OpenUriDoesNotThrowOnNull()
{
MockForms.Init();
MockForms.OpenUriAction = null;
Device.OpenUri(new Uri("https://www.google.com"));
Microsoft.Maui.Essentials.Launcher.OpenAsync(new Uri("https://www.google.com"));
}
[Test]
public void IdiomDesktop()
Expand Down
9 changes: 6 additions & 3 deletions Xamarin.Forms.Mocks.Tests/LoadFromXamlTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using NUnit.Framework;
using Xamarin.Forms.Xaml;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Graphics;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down Expand Up @@ -58,7 +61,7 @@ public void LoadViewCellWithTrigger ()
var app =
App.Current = new Application ();
var color =
app.Resources ["DisabledbackgroundColor"] = Color.LightGray;
app.Resources ["DisabledbackgroundColor"] = Colors.LightGray;
var cell = new SparePartViewCell ();
cell.BindingContext = new { IsEnabled = false };
var grid = cell.View as Grid;
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Mocks.Tests/NavigationTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.Maui.Controls;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down
56 changes: 29 additions & 27 deletions Xamarin.Forms.Mocks.Tests/OnPlatformTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using NUnit.Framework;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down Expand Up @@ -28,107 +30,107 @@ public void DefaultColor()
var platformColor = new OnPlatform<Color>();
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.RuntimePlatform }
});

Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void iOSColor()
{
MockForms.Init(Device.iOS);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.iOS }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void AndroidColor()
{
MockForms.Init(Device.Android);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.Android }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void GTKColor()
{
MockForms.Init(Device.GTK);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.GTK }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void macOSColor()
{
MockForms.Init(Device.macOS);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.macOS }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void UWPColor()
{
MockForms.Init(Device.UWP);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.UWP }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}

[Test]
public void WPFColor()
{
MockForms.Init(Device.WPF);

var platformColor = new OnPlatform<Color> { Default = Color.Blue };
var platformColor = new OnPlatform<Color> { Default = Colors.Blue };
platformColor.Platforms.Add(new On
{
Value = Color.Red,
Value = Colors.Red,
Platform = new[] { Device.WPF }
});

Assert.AreNotEqual(Color.Blue, (Color)platformColor);
Assert.AreEqual(Color.Red, (Color)platformColor);
Assert.AreNotEqual(Colors.Blue, (Color)platformColor);
Assert.AreEqual(Colors.Red, (Color)platformColor);
}
}
}
1 change: 1 addition & 0 deletions Xamarin.Forms.Mocks.Tests/PropertiesTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using NUnit.Framework;

namespace Xamarin.Forms.Mocks.Tests
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Mocks.Tests/Views/App.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Mocks.Tests.App">
<Application.Resources>
Expand Down
3 changes: 2 additions & 1 deletion Xamarin.Forms.Mocks.Tests/Views/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Maui.Controls;
using System;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down
3 changes: 1 addition & 2 deletions Xamarin.Forms.Mocks.Tests/Views/SparePartViewCell.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
<ViewCell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Mocks.Tests.SparePartViewCell">
<Grid Padding="10,0,0,10" IsEnabled="{Binding IsEnabled}" RowSpacing="0" AutomationId="SparePartViewCell">
<Grid.Triggers>
Expand Down
3 changes: 1 addition & 2 deletions Xamarin.Forms.Mocks.Tests/Views/SparePartViewCell.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Microsoft.Maui.Controls;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.Mocks.Tests/Views/TerribleExtension.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Xamarin.Forms.Xaml;
using Microsoft.Maui.Controls.Xaml;
using System;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Mocks.Tests/Views/TestView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Mocks.Tests.TestView">
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Mocks.Tests.TestView">
<Label Text="Woot" />
</ContentView>
3 changes: 2 additions & 1 deletion Xamarin.Forms.Mocks.Tests/Views/TestView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Maui.Controls;
using System;
using System.Collections.Generic;
using Xamarin.Forms;

Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Mocks.Tests/Views/TestViewCompiled.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Mocks.Tests.TestViewCompiled">
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Mocks.Tests.TestViewCompiled">
<Label Text="Compiled" />
</ContentView>
5 changes: 3 additions & 2 deletions Xamarin.Forms.Mocks.Tests/Views/TestViewCompiled.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Xamarin.Forms.Mocks.Tests
{
Expand Down
39 changes: 21 additions & 18 deletions Xamarin.Forms.Mocks.Tests/Xamarin.Forms.Mocks.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>Xamarin.Forms.Mocks.Tests</AssemblyName>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1269" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestAssembly\TestAssembly.csproj" />
<ProjectReference Include="..\Xamarin.Forms.Mocks\Xamarin.Forms.Mocks.csproj" />
<ProjectReference Include="..\Xamarin.Forms.Mocks.Xaml\Xamarin.Forms.Mocks.Xaml.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFrameworks>net6.0;</TargetFrameworks>
<UseMaui>true</UseMaui>
<AssemblyName>Xamarin.Forms.Mocks.Tests</AssemblyName>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestAssembly\TestAssembly.csproj" />
<ProjectReference Include="..\Xamarin.Forms.Mocks\Xamarin.Forms.Mocks.csproj" />
<ProjectReference Include="..\Xamarin.Forms.Mocks.Xaml\Xamarin.Forms.Mocks.Xaml.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit 13604bd

Please sign in to comment.