Skip to content

Commit 82933b2

Browse files
Merge pull request #6 from brminnick/Add-UI-Tests
Add ui tests
2 parents c6ebb57 + 4181cca commit 82933b2

25 files changed

+382
-12
lines changed

Src/AsyncAwaitBestPractices.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncAwaitBestPractices", "
1717
EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncAwaitBestPractices.UnitTests", "AsyncAwaitBestPractices.UnitTests\AsyncAwaitBestPractices.UnitTests.csproj", "{A7929DD1-B83F-4E39-9B66-56899819F054}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HackerNews.UITests", "HackerNews.UITests\HackerNews.UITests.csproj", "{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}"
21+
EndProject
22+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "HackerNews.Shared", "HackerNews.Shared\HackerNews.Shared.shproj", "{8551B218-5734-4F5C-9D35-25DB859CCFDE}"
23+
EndProject
2024
Global
2125
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2226
Debug|Any CPU = Debug|Any CPU
@@ -99,11 +103,25 @@ Global
99103
{A7929DD1-B83F-4E39-9B66-56899819F054}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
100104
{A7929DD1-B83F-4E39-9B66-56899819F054}.Debug|iPhone.ActiveCfg = Debug|Any CPU
101105
{A7929DD1-B83F-4E39-9B66-56899819F054}.Debug|iPhone.Build.0 = Debug|Any CPU
106+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
107+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|Any CPU.Build.0 = Debug|Any CPU
108+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|Any CPU.ActiveCfg = Release|Any CPU
109+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
111+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
112+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|iPhone.ActiveCfg = Release|Any CPU
113+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|iPhone.Build.0 = Release|Any CPU
114+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
115+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
116+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|iPhone.ActiveCfg = Debug|Any CPU
117+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43}.Debug|iPhone.Build.0 = Debug|Any CPU
102118
EndGlobalSection
103119
GlobalSection(NestedProjects) = preSolution
104120
{C3D6DE1F-ED08-4CA0-A092-56785BB3CB4D} = {2A09E240-E14C-45D9-8BE7-86EC6A5007DE}
105121
{6F319699-D810-4441-AF9F-4880C6AA2B03} = {2A09E240-E14C-45D9-8BE7-86EC6A5007DE}
106122
{E419B244-E072-4EAB-B1C7-07886925C217} = {2A09E240-E14C-45D9-8BE7-86EC6A5007DE}
107123
{A7929DD1-B83F-4E39-9B66-56899819F054} = {3CDAB3BD-D9EA-4BCD-8FA8-C103F2136337}
124+
{CCA4BF8B-7B64-4F7B-9C3A-AE498A65FD43} = {2A09E240-E14C-45D9-8BE7-86EC6A5007DE}
125+
{8551B218-5734-4F5C-9D35-25DB859CCFDE} = {2A09E240-E14C-45D9-8BE7-86EC6A5007DE}
108126
EndGlobalSection
109127
EndGlobal

Src/HackNews.Droid/HackerNews.Droid.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1818
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
1919
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
20+
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
2021
</PropertyGroup>
2122
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2223
<DebugSymbols>true</DebugSymbols>
@@ -26,11 +27,9 @@
2627
<DefineConstants>DEBUG;</DefineConstants>
2728
<ErrorReport>prompt</ErrorReport>
2829
<WarningLevel>4</WarningLevel>
29-
<AndroidLinkMode>None</AndroidLinkMode>
3030
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
3131
<AndroidTlsProvider>btls</AndroidTlsProvider>
3232
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
33-
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
3433
</PropertyGroup>
3534
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3635
<DebugSymbols>true</DebugSymbols>
@@ -139,6 +138,7 @@
139138
<Reference Include="Xamarin.Forms.Xaml">
140139
<HintPath>..\packages\Xamarin.Forms.3.4.0.1008975\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
141140
</Reference>
141+
<Reference Include="Mono.Android.Export" />
142142
</ItemGroup>
143143
<ItemGroup>
144144
<Compile Include="MainActivity.cs" />

Src/HackNews.Droid/MainActivity.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ protected override void OnCreate(Bundle savedInstanceState)
1919

2020
LoadApplication(new App());
2121
}
22+
23+
[Android.Runtime.Preserve, Java.Interop.Export(nameof(GetStoriesAsBase64String))]
24+
public string GetStoriesAsBase64String() => BackdoorMethodServices.GetStoriesAsBase64String();
2225
}
2326
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.minnick.HackerNews">
33
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="28" />
4+
<uses-permission android:name="android.permission.INTERNET" />
45
<application android:label="HackerNews"></application>
56
</manifest>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace HackerNews.Shared
2+
{
3+
public static class PageTitleConstants
4+
{
5+
public const string NewsPageTitle = "Top Stories";
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace HackerNews.Shared
2+
{
3+
public static class StoriesConstants
4+
{
5+
public const int NumberOfStories = 20;
6+
}
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
<HasSharedItems>true</HasSharedItems>
6+
<SharedGUID>{8551B218-5734-4F5C-9D35-25DB859CCFDE}</SharedGUID>
7+
</PropertyGroup>
8+
<PropertyGroup Label="Configuration">
9+
<Import_RootNamespace>HackerNews.Shared</Import_RootNamespace>
10+
</PropertyGroup>
11+
<ItemGroup>
12+
<Compile Include="$(MSBuildThisFileDirectory)Constants\PageTitleConstants.cs" />
13+
<Compile Include="$(MSBuildThisFileDirectory)Constants\StoriesConstants.cs" />
14+
<Compile Include="$(MSBuildThisFileDirectory)Models\StoryModel.cs" />
15+
</ItemGroup>
16+
<ItemGroup>
17+
<Folder Include="$(MSBuildThisFileDirectory)Models\" />
18+
<Folder Include="$(MSBuildThisFileDirectory)Constants\" />
19+
</ItemGroup>
20+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ProjectGuid>{8551B218-5734-4F5C-9D35-25DB859CCFDE}</ProjectGuid>
5+
</PropertyGroup>
6+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
7+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
8+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
9+
<Import Project="HackerNews.Shared.projitems" Label="Shared" />
10+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
11+
</Project>

Src/HackerNews/Models/StoryModel.cs renamed to Src/HackerNews.Shared/Models/StoryModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33

44
using Newtonsoft.Json;
55

6-
namespace HackerNews
6+
namespace HackerNews.Shared
77
{
88
public class StoryModel
9-
{
10-
public DateTimeOffset CreatedAt_DateTimeOffset => UnixTimeStampToDateTimeOffset(CreatedAt_UnixTime);
9+
{
10+
public DateTimeOffset CreatedAt_DateTimeOffset => UnixTimeStampToDateTimeOffset(CreatedAt_UnixTime);
1111

1212
[JsonProperty("by")]
1313
public string Author { get; set; }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Xamarin.UITest;
3+
4+
namespace HackerNews.UITests
5+
{
6+
public static class AppInitializer
7+
{
8+
public static IApp StartApp(Platform platform)
9+
{
10+
switch (platform)
11+
{
12+
case Platform.Android:
13+
return ConfigureApp.Android.StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear);
14+
case Platform.iOS:
15+
return ConfigureApp.iOS.StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear);
16+
default:
17+
throw new NotSupportedException();
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)