From f66c1d1c30d6670c550fd108e0240a6837e405d5 Mon Sep 17 00:00:00 2001 From: cldupland Date: Wed, 23 Oct 2019 12:00:21 +0200 Subject: [PATCH] Avancement de la vue test et ajout du projet test unitaire --- TestUnitaire/AppInitializer.cs | 42 ++++++++ TestUnitaire/TestUnitaire.csproj | 44 ++++++++ TestUnitaire/Tests.cs | 34 ++++++ TestUnitaire/packages.config | 5 + TheGameExtreme.sln | 14 +++ TheGameExtreme/TheGameExtreme.csproj | 4 +- TheGameExtreme/{ => view}/App.xaml | 0 TheGameExtreme/{ => view}/App.xaml.cs | 0 .../{ => view}/AppResources.Designer.cs | 4 +- TheGameExtreme/{ => view}/AppResources.resx | 0 TheGameExtreme/{ => view}/AssemblyInfo.cs | 0 TheGameExtreme/view/MainPage.xaml | 39 ++++--- TheGameExtreme/view/MainPage.xaml.cs | 19 ++-- TheGameExtreme/viewmodel/Main.cs | 101 ++++++++++++++---- 14 files changed, 257 insertions(+), 49 deletions(-) create mode 100644 TestUnitaire/AppInitializer.cs create mode 100644 TestUnitaire/TestUnitaire.csproj create mode 100644 TestUnitaire/Tests.cs create mode 100644 TestUnitaire/packages.config rename TheGameExtreme/{ => view}/App.xaml (100%) rename TheGameExtreme/{ => view}/App.xaml.cs (100%) rename TheGameExtreme/{ => view}/AppResources.Designer.cs (93%) rename TheGameExtreme/{ => view}/AppResources.resx (100%) rename TheGameExtreme/{ => view}/AssemblyInfo.cs (100%) diff --git a/TestUnitaire/AppInitializer.cs b/TestUnitaire/AppInitializer.cs new file mode 100644 index 0000000..af77aa0 --- /dev/null +++ b/TestUnitaire/AppInitializer.cs @@ -0,0 +1,42 @@ +using System; +using System.IO; +using System.Linq; +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace TestUnitaire +{ + public class AppInitializer + { + public static IApp StartApp(Platform platform) + { + // TODO: If the iOS or Android app being tested is included in the solution + // then open the Unit Tests window, right click Test Apps, select Add App Project + // and select the app projects that should be tested. + // + // The iOS project should have the Xamarin.TestCloud.Agent NuGet package + // installed. To start the Test Cloud Agent the following code should be + // added to the FinishedLaunching method of the AppDelegate: + // + // #if ENABLE_TEST_CLOUD + // Xamarin.Calabash.Start(); + // #endif + if (platform == Platform.Android) + { + return ConfigureApp + .Android + // TODO: Update this path to point to your Android app and uncomment the + // code if the app is not included in the solution. + //.ApkFile ("../../../Droid/bin/Debug/xamarinforms.apk") + .StartApp(); + } + + return ConfigureApp + .iOS + // TODO: Update this path to point to your iOS app and uncomment the + // code if the app is not included in the solution. + //.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/XamarinForms.iOS.app") + .StartApp(); + } + } +} diff --git a/TestUnitaire/TestUnitaire.csproj b/TestUnitaire/TestUnitaire.csproj new file mode 100644 index 0000000..c3bb5ac --- /dev/null +++ b/TestUnitaire/TestUnitaire.csproj @@ -0,0 +1,44 @@ + + + + Debug + AnyCPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1} + Library + TestUnitaire + TestUnitaire + v4.7.2 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + + ..\packages\Xamarin.UITest.2.2.7\lib\net45\Xamarin.UITest.dll + + + + + + + + + + + \ No newline at end of file diff --git a/TestUnitaire/Tests.cs b/TestUnitaire/Tests.cs new file mode 100644 index 0000000..8a34a6d --- /dev/null +++ b/TestUnitaire/Tests.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Linq; +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace TestUnitaire +{ + [TestFixture(Platform.Android)] + [TestFixture(Platform.iOS)] + public class Tests + { + IApp app; + Platform platform; + + public Tests(Platform platform) + { + this.platform = platform; + } + + [SetUp] + public void BeforeEachTest() + { + app = AppInitializer.StartApp(platform); + } + + [Test] + public void AppLaunches() + { + app.Screenshot("First screen."); + } + } +} diff --git a/TestUnitaire/packages.config b/TestUnitaire/packages.config new file mode 100644 index 0000000..11318d5 --- /dev/null +++ b/TestUnitaire/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/TheGameExtreme.sln b/TheGameExtreme.sln index 91580fa..d542605 100644 --- a/TheGameExtreme.sln +++ b/TheGameExtreme.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme.iOS", "TheGa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -53,5 +55,17 @@ Global {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Debug|iPhone.Build.0 = Debug|Any CPU {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.ActiveCfg = Release|Any CPU {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.Build.0 = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.Build.0 = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhone.Build.0 = Debug|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.ActiveCfg = Release|Any CPU + {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/TheGameExtreme/TheGameExtreme.csproj b/TheGameExtreme/TheGameExtreme.csproj index ebbb853..d583dae 100644 --- a/TheGameExtreme/TheGameExtreme.csproj +++ b/TheGameExtreme/TheGameExtreme.csproj @@ -30,13 +30,13 @@ - + PublicResXFileCodeGenerator AppResources.Designer.cs - + AppResources.resx diff --git a/TheGameExtreme/App.xaml b/TheGameExtreme/view/App.xaml similarity index 100% rename from TheGameExtreme/App.xaml rename to TheGameExtreme/view/App.xaml diff --git a/TheGameExtreme/App.xaml.cs b/TheGameExtreme/view/App.xaml.cs similarity index 100% rename from TheGameExtreme/App.xaml.cs rename to TheGameExtreme/view/App.xaml.cs diff --git a/TheGameExtreme/AppResources.Designer.cs b/TheGameExtreme/view/AppResources.Designer.cs similarity index 93% rename from TheGameExtreme/AppResources.Designer.cs rename to TheGameExtreme/view/AppResources.Designer.cs index 745769e..169b709 100644 --- a/TheGameExtreme/AppResources.Designer.cs +++ b/TheGameExtreme/view/AppResources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TheGameExtreme { +namespace TheGameExtreme.view { using System; using System.Reflection; @@ -30,7 +30,7 @@ namespace TheGameExtreme { public static System.Resources.ResourceManager ResourceManager { get { if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.AppResources", typeof(AppResources).Assembly); + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.view.AppResources", typeof(AppResources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/TheGameExtreme/AppResources.resx b/TheGameExtreme/view/AppResources.resx similarity index 100% rename from TheGameExtreme/AppResources.resx rename to TheGameExtreme/view/AppResources.resx diff --git a/TheGameExtreme/AssemblyInfo.cs b/TheGameExtreme/view/AssemblyInfo.cs similarity index 100% rename from TheGameExtreme/AssemblyInfo.cs rename to TheGameExtreme/view/AssemblyInfo.cs diff --git a/TheGameExtreme/view/MainPage.xaml b/TheGameExtreme/view/MainPage.xaml index d8bc594..fbb8ebb 100644 --- a/TheGameExtreme/view/MainPage.xaml +++ b/TheGameExtreme/view/MainPage.xaml @@ -1,24 +1,33 @@  - + - - -