feat : binding tag
continuous-integration/drone/push Build is failing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent d3b2ce4b12
commit 000eecc4ea

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
@ -53,28 +54,28 @@ namespace Model
}
private string cover;
public string[] Tags
public ObservableCollection<string> Tags
{
get => tags;
set
{
if (value == null || value.Length != 3) return;
if (value == null || value.Count != 3) return;
tags = value;
}
}
private string[]? tags;
private ObservableCollection<string> tags;
public event PropertyChangedEventHandler? PropertyChanged;
public List<Review> Reviews { get; private init; }
public Game(string name, string description, int year, string[] tags, string cover)
public Game(string name, string description, int year, List<string> c_tags, string cover)
{
Name = name;
Description = description;
Year = year;
tags = new string[3];
Tags = tags;
if (c_tags != null) tags = new ObservableCollection<string>(c_tags);
else tags = new ObservableCollection<string>();
Cover= cover;
Reviews = new List<Review>();
}
@ -102,9 +103,9 @@ namespace Model
{
description = newdesc;
}
public void TagChange(string[] newtag)
public void TagChange(List<string> newtag)
{
tags=newtag;
if (newtag != null && newtag.Count==3) tags = new ObservableCollection<string>(newtag);
}
public void NameChange(string newname)
{

@ -15,10 +15,10 @@ namespace Model
public Manager(IPersistance persistance)
{
_persistance = persistance;
Games.Add(new("Elden Ring", "description", 2010, new string[3] { "1", "2", "3" }, "elden_ring.jpg"));
Games.Add(new("Minecraft", "description", 2010, new string[3] { "1", "2", "3" }, "minecraft.jpeg"));
Games.Add(new("Celeste", "description", 2010, new string[3] { "1", "2", "3" }, "celeste.png"));
Games.Add(new("GTA V", "description", 2010, new string[3] { "1", "2", "3" }, "gta_v.png"));
Games.Add(new("Elden Ring", "description", 2010, new List<string> { "1","2","3"}, "elden_ring.jpg"));
Games.Add(new("Minecraft", "description", 2010, new List<string> { "1", "2", "3" }, "minecraft.jpeg"));
Games.Add(new("Celeste", "description", 2010, new List<string> { "1", "2", "3" }, "celeste.png"));
Games.Add(new("GTA V", "description", 2010, new List<string> { "1", "2", "3" }, "gta_v.png"));
}
}
}

@ -35,7 +35,7 @@
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding Cover}" Aspect="AspectFit" Margin="0,0,0,0" />
<Image Source="{Binding Cover}" Aspect="AspectFit" Margin="0,0,0,0" WidthRequest="600" HeightRequest="750"/>
<Label TextColor="White" FontAttributes="Bold" FontSize="30" Margin="5" FontFamily="arial" Text="{Binding Name}" Grid.Row="1" HorizontalTextAlignment="Center"/>
<Grid Grid.Row="2">
@ -52,9 +52,13 @@
</Grid.RowDefinitions>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text="Tag :" Grid.Row="0"/>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text=" - Game of the year" Grid.Row="1"/>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text=" - RPG" Grid.Row="2"/>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text=" - Souls" Grid.Row="3"/>
<CollectionView ItemsSource="{Binding Tags}" SelectionMode="Single" ItemsLayout="HorizontalGrid, 3" Grid.Row="1" Grid.Column="0">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text="{Binding}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<Label TextColor="White" FontSize="15" Margin="5" FontFamily="arial" Text="{Binding Year}" Grid.Column="2" HorizontalTextAlignment="End" VerticalTextAlignment="End"/>
</Grid>

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
internal class TestAdmin
{
}
}

@ -7,73 +7,74 @@ namespace Test
[Fact]
public void Constructeur()
{
string[] tags = { "1", "2", "3"};
Game game = new("game", "description", 2012, tags, "cover");
Game game = new("game", "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.NotNull(game);
}
[Fact]
public void Name()
{
string[] tags = { "1", "2", "3" };
Game game = new("", "description", 2012, tags, "cover");
Game game = new("", "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Null(game.Name);
Game game2 = new(null, "description", 2012, tags, "cover");
Game game2 = new(null, "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Null(game2.Name);
Game game3 = new("good", "description", 2012, tags, "cover");
Game game3 = new("good", "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Equal("good", game3.Name);
}
[Fact]
public void Description()
{
string[] tags = { "1", "2", "3" };
Game game = new("name", "", 2012, tags, "cover");
Game game = new("name", "", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Null(game.Description);
Game game2 = new("name", null, 2012, tags, "cover");
Game game2 = new("name", null, 2012, new List<String> {"1","2","3"}, "cover");
Assert.Null(game2.Description);
Game game3 = new("name", "good", 2012, tags, "cover");
Game game3 = new("name", "good", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Equal("good", game3.Description);
}
[Fact]
public void Year()
{
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 1111, tags, "cover");
Game game = new("name", "description", 1111, new List<String> {"1","2","3"}, "cover");
Assert.Equal(0, game.Year);
Game game2 = new("name", "description", 9999, tags, "cover");
Game game2 = new("name", "description", 9999, new List<String> {"1","2","3"}, "cover");
Assert.Equal(0, game2.Year);
Game game3 = new("name", "description", 2012, tags, "cover");
Game game3 = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.Equal(2012, game3.Year);
}
[Fact]
public void Tags()
{
string[] tags = { "1", "2" }, tags2 = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Assert.All(game.Tags, Assert.Null);
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
Assert.NotNull(game.Tags);
Game game2 = new("name", "description", 2012, null, "cover");
Assert.All(game.Tags, Assert.Null);
Assert.NotNull(game2.Tags);
Assert.Empty(game2.Tags);
Game game3 = new("name", "description", 2012, tags2, "cover");
Game game3 = new("name", "description", 2012, new List<String> {"1","2"}, "cover");
Assert.NotNull(game3.Tags);
Assert.Empty(game3.Tags);
}
[Fact]
public void AddReview()
{
Review r1 = new(2.5f, "cool"), r2 = new(4, "tres cool"), r3 = new(1, "pas cool");
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.AddReview(r1);
game.AddReview(r2);
@ -86,8 +87,8 @@ namespace Test
public void RemoveReview()
{
Review r1 = new(2.5f, "cool"), r2 = new(4, "tres cool"), r3 = new(1, "pas cool");
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.AddReview(r1);
game.AddReview(r2);
@ -100,8 +101,8 @@ namespace Test
[Fact]
public void ChangeName()
{
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.NameChange("newName");
Assert.Equal("newName", game.Name);
@ -110,8 +111,8 @@ namespace Test
[Fact]
public void ChangeDescription()
{
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.DescChange("newDesc");
Assert.Equal("newDesc", game.Description);
@ -120,8 +121,8 @@ namespace Test
[Fact]
public void ChangeYear()
{
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.YearChange(2020);
Assert.Equal(2020, game.Year);
@ -130,19 +131,18 @@ namespace Test
[Fact]
public void ChangeTags()
{
string[] tags = { "1", "2", "3" }, tags2 = { "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> { "1", "2", "3" }, "cover");
game.NameChange("newName");
game.TagChange(tags2);
Assert.DoesNotContain("1", game.Tags);
game.TagChange(new List<String> { "1", "2" });
Assert.Empty(game.Tags);
}
[Fact]
public void Average()
{
Review r1 = new(2.5f, "cool"), r2 = new(4, "tres cool"), r3 = new(1, "pas cool");
string[] tags = { "1", "2", "3" };
Game game = new("name", "description", 2012, tags, "cover");
Game game = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover");
game.AddReview(r1);
game.AddReview(r2);

@ -66,7 +66,7 @@ namespace Test
Assert.NotNull(user);
Assert.Empty(user.Followed_Games);
Game game = new("name", "description", 2012, new string[] { "1", "2", "3" }, "cover");
Game game = new("name", "description", 2012, new List<String> { "1", "2", "3" }, "cover");
Assert.NotNull(game);
user.FollowAGame(game);
Assert.Single(user.Followed_Games);

Loading…
Cancel
Save