Avancement de la vue test et ajout du projet test unitaire

master
cldupland 6 years ago
parent cb7ded95af
commit f66c1d1c30

@ -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();
}
}
}

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>TestUnitaire</RootNamespace>
<AssemblyName>TestUnitaire</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Xamarin.UITest">
<HintPath>..\packages\Xamarin.UITest.2.2.7\lib\net45\Xamarin.UITest.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Tests.cs" />
<Compile Include="AppInitializer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

@ -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.");
}
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.3" targetFramework="net472" />
<package id="Xamarin.UITest" version="2.2.7" targetFramework="net472" />
</packages>

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme.iOS", "TheGa
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.Build.0 = 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 EndGlobalSection
EndGlobal EndGlobal

@ -30,13 +30,13 @@
<None Remove="AppRessources.config" /> <None Remove="AppRessources.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="AppResources.resx"> <EmbeddedResource Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " Update="view\AppResources.resx">
<Generator>PublicResXFileCodeGenerator</Generator> <Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput> <LastGenOutput>AppResources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="AppResources.Designer.cs"> <Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="view\AppResources.Designer.cs">
<DependentUpon>AppResources.resx</DependentUpon> <DependentUpon>AppResources.resx</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace TheGameExtreme { namespace TheGameExtreme.view {
using System; using System;
using System.Reflection; using System.Reflection;
@ -30,7 +30,7 @@ namespace TheGameExtreme {
public static System.Resources.ResourceManager ResourceManager { public static System.Resources.ResourceManager ResourceManager {
get { get {
if (object.Equals(null, resourceMan)) { 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; resourceMan = temp;
} }
return resourceMan; return resourceMan;

@ -1,24 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="TheGameExtreme.MainPage"> <ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="TheGameExtreme.MainPage">
<StackLayout> <StackLayout>
<!-- Place new controls here --> <!-- Place new controls here -->
<StackLayout <StackLayout
Orientation="Horizontal"> Orientation="Horizontal">
<Label x:Name="pile0" Text="coucou:" /> <Label x:Name="pile0" />
<Label x:Name="pile1" Text="hey"/> <Label x:Name="pile1" />
<Label x:Name="pile2" Text="hi"/> <Label x:Name="pile2" />
<Label x:Name="pile3" Text="hello"/> <Label x:Name="pile3" />
</StackLayout> </StackLayout>
<StackLayout x:Name="handCard" <ScrollView
Orientation="Horizontal"> Orientation="Horizontal">
<Button x:Uid="card1" x:Name="card1" Clicked="played" Text="Card 1" /> <StackLayout
<Button x:Uid="card2" x:Name="card2" Clicked="played" Text="Card 2" /> Orientation="Horizontal">
<Button x:Uid="card3" x:Name="card3" Clicked="played" Text="Card 3" /> <Button CommandParameter="card1" x:Name="card1" Clicked="played" />
<Button x:Uid="card4" x:Name="card4" Clicked="played" Text="Card 4" /> <Button CommandParameter="card2" x:Name="card2" Clicked="played" />
<Button x:Uid="card5" x:Name="card5" Clicked="played" Text="Card 5" /> <Button CommandParameter="card3" x:Name="card3" Clicked="played" />
<Button x:Uid="card6" x:Name="card6" Clicked="played" Text="Card 6" /> <Button CommandParameter="card4" x:Name="card4" Clicked="played" />
<Button x:Uid="card7" x:Name="card7" Clicked="played" Text="Card 7" /> <Button CommandParameter="card5" x:Name="card5" Clicked="played" />
<Button CommandParameter="card6" x:Name="card6" Clicked="played" />
<Button CommandParameter="card7" x:Name="card7" Clicked="played" />
</StackLayout> </StackLayout>
</ScrollView>
<Button Text="End Turn" Clicked="endTurn"/> <Button Text="End Turn" Clicked="endTurn"/>
</StackLayout> </StackLayout>
</ContentPage> </ContentPage>

@ -25,17 +25,22 @@ namespace TheGameExtreme
{ {
InitializeComponent(); InitializeComponent();
pile0.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack0)); pile0.SetBinding(Label.TextProperty, new Binding("Stack0", source: viewmodel));
pile1.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack1)); pile1.SetBinding(Label.TextProperty, new Binding("Stack1", source: viewmodel));
pile2.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack2)); pile2.SetBinding(Label.TextProperty, new Binding("Stack2", source: viewmodel));
//pile3.SetBinding(Label.TextProperty, new Binding("Value", source: viewmodel.Stack3)); pile3.SetBinding(Label.TextProperty, new Binding("Stack3", source: viewmodel));
//card1.SetBinding(Button.TextProperty, new Binding("Text", source: viewmodel.)) card1.SetBinding(Button.TextProperty, new Binding("ValueCard1", source: viewmodel));
card2.SetBinding(Button.TextProperty, new Binding("ValueCard2", source: viewmodel));
card3.SetBinding(Button.TextProperty, new Binding("ValueCard3", source: viewmodel));
card4.SetBinding(Button.TextProperty, new Binding("ValueCard4", source: viewmodel));
card5.SetBinding(Button.TextProperty, new Binding("ValueCard5", source: viewmodel));
card6.SetBinding(Button.TextProperty, new Binding("ValueCard6", source: viewmodel));
card7.SetBinding(Button.TextProperty, new Binding("ValueCard7", source: viewmodel));
} }
private void played(object sender, EventArgs args) private void played(object sender, EventArgs args)
{ {
string text = (sender as Button).Text; viewmodel.played((sender as Button).CommandParameter as string);
viewmodel.played(text);
} }
private void endTurn(object sender, EventArgs args) private void endTurn(object sender, EventArgs args)

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using TheGameExtreme.model; using TheGameExtreme.model;
using TheGameExtreme.model.@event; using TheGameExtreme.model.@event;
using TheGameExtreme.model.manager; using TheGameExtreme.model.manager;
@ -7,19 +8,76 @@ using Xamarin.Forms;
namespace TheGameExtreme.viewmodel namespace TheGameExtreme.viewmodel
{ {
public class Main public class Main : INotifyPropertyChanged
{ {
private List<Player> players; private List<Player> players;
private GameManager gameManager; private GameManager gameManager;
private int currentIndexPlayer; private int currentIndexPlayer;
public string Stack0 { get; set; } = "1";
public string Stack1 { get; set; } = "1"; public event PropertyChangedEventHandler PropertyChanged;
public string Stack2 { get; set; } = "100"; private string stack0;
public string Stack3 { get; set; } = "100"; public String Stack0
{
get { return stack0; }
set
{
stack0 = value;
OnPropertyChanged("Stack0");
}
}
public string stack1;
public String Stack1
{
get { return stack1; }
set
{
stack1 = value;
OnPropertyChanged("Stack1");
}
}
public string stack2;
public String Stack2
{
get { return stack2; }
set
{
stack2 = value;
OnPropertyChanged("Stack2");
}
}
public string stack3;
public String Stack3
{
get { return stack3; }
set
{
stack3 = value;
OnPropertyChanged("Stack3");
}
}
private int valueCard1;
public int ValueCard1
{
get { return valueCard1; }
set
{
valueCard1 = value;
OnPropertyChanged("ValueCard1");
}
}
private void OnPropertyChanged(string v)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(v));
}
public Main() public Main()
{ {
stack0 = "1";
stack1 = "1";
stack2 = "100";
stack3 = "100";
players = new List<Player> { new Player("Clément"), new Player("Baptiste") }; players = new List<Player> { new Player("Clément"), new Player("Baptiste") };
gameManager = new SoloGameManager(2, players); gameManager = new SoloGameManager(2, players);
@ -30,7 +88,8 @@ namespace TheGameExtreme.viewmodel
player.HandCardChanged += OnHandCardChanged; player.HandCardChanged += OnHandCardChanged;
}); });
gameManager.CurrentPlayerChanged += OnCurrentPlayerChanged; gameManager.CurrentPlayerChanged += OnCurrentPlayerChanged;
// Ecoute le changement de vue
valueCard1 = players[currentIndexPlayer].getCardList()[0].Value;
} }
public void OnTopRangeChanged(object source, TopRangeChangedEventArgs args) public void OnTopRangeChanged(object source, TopRangeChangedEventArgs args)
@ -38,7 +97,7 @@ namespace TheGameExtreme.viewmodel
switch (args.NumStackChanged) switch (args.NumStackChanged)
{ {
case 0: case 0:
Stack0 = args.NewTopRangeCard.Value.ToString(); stack0 = args.NewTopRangeCard.Value.ToString();
break; break;
case 1: case 1:
Stack1 = args.NewTopRangeCard.Value.ToString(); Stack1 = args.NewTopRangeCard.Value.ToString();
@ -52,17 +111,13 @@ namespace TheGameExtreme.viewmodel
} }
} }
private void OnHandCardChanged(object source, HandCardChangedEventArgs args) private void OnHandCardChanged(object source, HandCardChangedEventArgs args) // Double les appels car les joueurs sont les mêmes dans le model et ici
{
players[currentIndexPlayer].getCardList().ForEach(card =>
{ {
//if (args.NewHandCard == null)
//{
// players[currentIndexPlayer].getCardList().Remove(args.OldHandCard);
//}
//else
//{
// players[currentIndexPlayer].getCardList().Add(args.NewHandCard);
//}
});
valueCard1 = players[currentIndexPlayer].getCardList()[0].Value;
} }
private void OnCurrentPlayerChanged(object source, CurrentPlayerChangedEventArgs args) private void OnCurrentPlayerChanged(object source, CurrentPlayerChangedEventArgs args)
@ -87,25 +142,25 @@ namespace TheGameExtreme.viewmodel
{ {
switch (text) switch (text)
{ {
case "Card 1": case "card1":
gameManager.joue(players[currentIndexPlayer].getCardList()[0], r); gameManager.joue(players[currentIndexPlayer].getCardList()[0], r);
break; break;
case "Card 2": case "card2":
gameManager.joue(players[currentIndexPlayer].getCardList()[1], r); gameManager.joue(players[currentIndexPlayer].getCardList()[1], r);
break; break;
case "Card 3": case "card3":
gameManager.joue(players[currentIndexPlayer].getCardList()[2], r); gameManager.joue(players[currentIndexPlayer].getCardList()[2], r);
break; break;
case "Card 4": case "card4":
gameManager.joue(players[currentIndexPlayer].getCardList()[3], r); gameManager.joue(players[currentIndexPlayer].getCardList()[3], r);
break; break;
case "Card 5": case "card5":
gameManager.joue(players[currentIndexPlayer].getCardList()[4], r); gameManager.joue(players[currentIndexPlayer].getCardList()[4], r);
break; break;
case "Card 6": case "card6":
gameManager.joue(players[currentIndexPlayer].getCardList()[5], r); gameManager.joue(players[currentIndexPlayer].getCardList()[5], r);
break; break;
case "Card 7": case "card7":
gameManager.joue(players[currentIndexPlayer].getCardList()[6], r); gameManager.joue(players[currentIndexPlayer].getCardList()[6], r);
break; break;
} }

Loading…
Cancel
Save