Feat : Oui c'est moi, je viens de doubler le coverage du manager
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 03b4d2f20e
commit 11fd5fd658

@ -51,10 +51,14 @@
</VerticalStackLayout>
</DataTemplate>
<DataTemplate x:Key="followTemplate">
<Border HeightRequest="150">
<Grid ColumnDefinitions="*, *" RowDefinitions="*">
<Border HeightRequest="150" Margin="10">
<Grid ColumnDefinitions="auto,*,3*,auto" RowDefinitions="*">
<Image Source="{Binding Cover}"/>
<Label Grid.Column="1" Text="{Binding Name}"/>
<Label Grid.Column="1" Text="{Binding Name}" FontSize="50"/>
<ScrollView Grid.Column="2">
<Label Text="{Binding Description}"/>
</ScrollView>
<CollectionView Grid.Column="3" ItemsSource="{Binding Tags}" Grid.Row="1" Margin="0" ItemTemplate="{StaticResource tagsTemplate}" HorizontalOptions="End"/>
</Grid>
</Border>
</DataTemplate>

@ -47,8 +47,21 @@ public partial class DetailledPage : ContentPage
}
private async void AddFollow(object sender, EventArgs e)
{
bool flag = false;
foreach (Game game in ((App)App.Current).Manager.CurrentUser.Followed_Games)
{
if (game == null) throw new Exception();
else if (currentGame == game) { flag = true; break; }
}
if (!flag)
{
await this.ShowPopupAsync(new MessagePopup("Jeu ajouté dans les suivis !"));
((App)App.Current).Manager.CurrentUser.FollowAGame(currentGame);
}
else
{
await this.ShowPopupAsync(new MessagePopup("Jeu déjà suivis !"));
}
}
}

@ -20,7 +20,6 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.RowSpan="2"/>
<CollectionView ItemsSource="{Binding Followed_Games}" SelectionMode="Single" Grid.Column="1" SelectionChanged="GoToDetail" ItemTemplate="{StaticResource followTemplate}"/>
</Grid>
</ScrollView>
</ContentPage>

@ -36,5 +36,103 @@ namespace Test
Assert.Contains(user, manager.Users);
}
[Fact]
public void GetSetCurrentUser()
{
IPersistance persistance = new Stub();
Manager manager = new(persistance);
manager.CurrentUser = new("", "username", "", "gmail@gmail.com", "Azerty123*");
Assert.Equal(new("", "username", "", "gmail@gmail.com", "Azerty123*"), manager.CurrentUser);
User user = manager.CurrentUser;
Assert.Equal(manager.CurrentUser, user);
}
[Fact]
public void GetSetSelectedGame()
{
IPersistance persistance = new Stub();
Manager manager = new(persistance);
manager.SelectedGame = new("game", "description", 2012, new List<String> { "1", "2", "3" }, "cover", "www.link.com");
Assert.Equal(new("game", "description", 2012, new List<String> { "1", "2", "3" }, "cover", "www.link.com"), manager.SelectedGame);
Game game = manager.SelectedGame;
Assert.Equal(manager.SelectedGame, game);
}
[Fact]
public void FilterGames()
{
IPersistance persistance = new Stub();
Manager manager = new(persistance);
var compList = manager.FilterGames(null, null, null);
var list = manager.FilterGames(null,null,null);
Assert.Equal(list,manager.GameList);
List<Game> compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList;
list = manager.FilterGames("Elden Ring",null, null);
foreach (var game in manager.GameList)
{
if (game.Name=="Elden Ring")
{
compListAsList = compList.ToList();
compListAsList.Add(game);
compList = compListAsList;
break;
}
}
Assert.Equal(compList, list);
compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList;
list = manager.FilterGames(null, "Action", null);
foreach (var game in manager.GameList)
{
if (game.Tags.Any(tag=>tag == "Action"))
{
compListAsList = compList.ToList();
compListAsList.Add(game);
compList = compListAsList;
break;
}
}
Assert.Equal(compList, list);
list = manager.FilterGames(null,null, "Action");
Assert.Equal(compList, list);
compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList; list = manager.FilterGames("Elden Ring", "Action", null);
foreach (var game in manager.GameList)
{
if (game.Name=="Elden Ring" && game.Tags.Any(tag => tag == "Action"))
{
compListAsList = compList.ToList();
compListAsList.Add(game);
compList = compListAsList;
break;
}
}
Assert.Equal(compList, list);
list = manager.FilterGames("Elden Ring", null, "Action");
Assert.Equal(compList, list);
compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList; list = manager.FilterGames("Elden Ring", "Action", "Solo");
foreach (var game in manager.GameList)
{
if (game.Name=="Elden Ring" && game.Tags.Any(tag => tag == "Action" && game.Tags.Any(tag => tag == "Solo")))
{
compListAsList = compList.ToList();
compListAsList.Add(game);
compList = compListAsList;
break;
}
}
Assert.Equal(compList, list);
}
}
}

Loading…
Cancel
Save