pull/60/head
victor perez ngounou 3 years ago
parent 222a7d2aa7
commit 295538a456

Binary file not shown.

@ -1,151 +0,0 @@
// <auto-generated />
using System;
using BowlingEF.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BowlingEF.Migrations
{
[DbContext(typeof(BowlingContext))]
[Migration("20221015045144_migration001")]
partial class migration001
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Nom")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Equipes");
});
modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<bool>("IsSpare")
.HasColumnType("INTEGER");
b.Property<bool>("IsStrike")
.HasColumnType("INTEGER");
b.Property<int>("Lancer1")
.HasColumnType("INTEGER");
b.Property<int>("Lancer2")
.HasColumnType("INTEGER");
b.Property<int>("Lancer3")
.HasColumnType("INTEGER");
b.Property<int>("Numero")
.HasColumnType("INTEGER");
b.Property<long>("PartieId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PartieId");
b.ToTable("Frames");
});
modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("EquipeEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EquipeEntityId");
b.ToTable("Joueurs");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("JoueurId")
.HasColumnType("INTEGER");
b.Property<int>("Score")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("JoueurId");
b.ToTable("Parties");
});
modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b =>
{
b.HasOne("BowlingEF.Entities.PartieEntity", "Partie")
.WithMany("Frames")
.HasForeignKey("PartieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Partie");
});
modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b =>
{
b.HasOne("BowlingEF.Entities.EquipeEntity", null)
.WithMany("Joueurs")
.HasForeignKey("EquipeEntityId");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.HasOne("BowlingEF.Entities.JoueurEntity", "Joueur")
.WithMany()
.HasForeignKey("JoueurId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Joueur");
});
modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b =>
{
b.Navigation("Joueurs");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.Navigation("Frames");
});
#pragma warning restore 612, 618
}
}
}

@ -1,119 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BowlingEF.Migrations
{
public partial class migration001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Equipes",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nom = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Equipes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Joueurs",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
EquipeEntityId = table.Column<long>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Joueurs", x => x.Id);
table.ForeignKey(
name: "FK_Joueurs_Equipes_EquipeEntityId",
column: x => x.EquipeEntityId,
principalTable: "Equipes",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Parties",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
JoueurId = table.Column<long>(type: "INTEGER", nullable: false),
Score = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Parties", x => x.Id);
table.ForeignKey(
name: "FK_Parties_Joueurs_JoueurId",
column: x => x.JoueurId,
principalTable: "Joueurs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Frames",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Numero = table.Column<int>(type: "INTEGER", nullable: false),
Lancer1 = table.Column<int>(type: "INTEGER", nullable: false),
Lancer2 = table.Column<int>(type: "INTEGER", nullable: false),
Lancer3 = table.Column<int>(type: "INTEGER", nullable: false),
IsStrike = table.Column<bool>(type: "INTEGER", nullable: false),
IsSpare = table.Column<bool>(type: "INTEGER", nullable: false),
PartieId = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Frames", x => x.Id);
table.ForeignKey(
name: "FK_Frames_Parties_PartieId",
column: x => x.PartieId,
principalTable: "Parties",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Frames_PartieId",
table: "Frames",
column: "PartieId");
migrationBuilder.CreateIndex(
name: "IX_Joueurs_EquipeEntityId",
table: "Joueurs",
column: "EquipeEntityId");
migrationBuilder.CreateIndex(
name: "IX_Parties_JoueurId",
table: "Parties",
column: "JoueurId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Frames");
migrationBuilder.DropTable(
name: "Parties");
migrationBuilder.DropTable(
name: "Joueurs");
migrationBuilder.DropTable(
name: "Equipes");
}
}
}

@ -1,149 +0,0 @@
// <auto-generated />
using System;
using BowlingEF.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BowlingEF.Migrations
{
[DbContext(typeof(BowlingContext))]
partial class BowlingContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Nom")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Equipes");
});
modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<bool>("IsSpare")
.HasColumnType("INTEGER");
b.Property<bool>("IsStrike")
.HasColumnType("INTEGER");
b.Property<int>("Lancer1")
.HasColumnType("INTEGER");
b.Property<int>("Lancer2")
.HasColumnType("INTEGER");
b.Property<int>("Lancer3")
.HasColumnType("INTEGER");
b.Property<int>("Numero")
.HasColumnType("INTEGER");
b.Property<long>("PartieId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PartieId");
b.ToTable("Frames");
});
modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long?>("EquipeEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EquipeEntityId");
b.ToTable("Joueurs");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("JoueurId")
.HasColumnType("INTEGER");
b.Property<int>("Score")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("JoueurId");
b.ToTable("Parties");
});
modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b =>
{
b.HasOne("BowlingEF.Entities.PartieEntity", "Partie")
.WithMany("Frames")
.HasForeignKey("PartieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Partie");
});
modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b =>
{
b.HasOne("BowlingEF.Entities.EquipeEntity", null)
.WithMany("Joueurs")
.HasForeignKey("EquipeEntityId");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.HasOne("BowlingEF.Entities.JoueurEntity", "Joueur")
.WithMany()
.HasForeignKey("JoueurId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Joueur");
});
modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b =>
{
b.Navigation("Joueurs");
});
modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b =>
{
b.Navigation("Frames");
});
#pragma warning restore 612, 618
}
}
}

@ -1,86 +1,86 @@
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using BowlingLib.Model;
using Xunit;
namespace Test.BowlingAppUnitTest
{
public class UnitTestEquipe
{
public static IEnumerable<object[]> Data_AddJoueurToEquipe()
{
yield return new object[]
{
true,
new Joueur[]
{
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania"),
new Joueur("Cornelle")
},
new Equipe("ABRMC",
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")),
new Joueur("Cornelle")
};
yield return new object[]
{
false,
new Joueur[]
{
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")
},
new Equipe("ABRMC",
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")),
new Joueur("Mania")
};
}
[Theory]
[MemberData(nameof(Data_AddJoueurToEquipe))]
public void Test_AddJoueurToEquipe(bool expectedResult,
Joueur[] expectedJoueurs,
Equipe equipe,
Joueur joueur)
{
bool result = equipe.AjouterJoueur(joueur);
Assert.Equal(expectedResult, result);
Assert.Equal(expectedJoueurs.Length, equipe.GetJoueurs().Count);
Assert.All(expectedJoueurs, j => equipe.Joueurs.Contains(j));
using Xunit;
namespace Test.BowlingAppUnitTest
{
public class UnitTestEquipe
{
public static IEnumerable<object[]> Data_AddJoueurToEquipe()
{
yield return new object[]
{
true,
new Joueur[]
{
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania"),
new Joueur("Cornelle")
},
new Equipe("ABRMC",
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")),
new Joueur("Cornelle")
};
yield return new object[]
{
false,
new Joueur[]
{
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")
},
new Equipe("ABRMC",
new Joueur("Alys"),
new Joueur("Bénita"),
new Joueur("Regis"),
new Joueur("Mania")),
new Joueur("Mania")
};
}
[Theory]
[MemberData(nameof(Data_AddJoueurToEquipe))]
public void Test_AddJoueurToEquipe(bool expectedResult,
Joueur[] expectedJoueurs,
Equipe equipe,
Joueur joueur)
{
bool result = equipe.AjouterJoueur(joueur);
Assert.Equal(expectedResult, result);
Assert.Equal(expectedJoueurs.Length, equipe.GetJoueurs().Count);
Assert.All(expectedJoueurs, j => equipe.Joueurs.Contains(j));
}
[Theory]
[MemberData(nameof(TestData.Data_AddJoueurToEquipe), MemberType=typeof(TestData))]
[MemberData(nameof(TestData.Data_AddJoueurToEquipe), MemberType=typeof(TestData))]
public void Test_AddJoueursToEquipe(int expectedResult,
Joueur[] expectedJoueurs,
Joueur[] expectedAddedJoueurs,
Equipe equipe,
params Joueur[] joueursToAdd)
{
var addedJoueurs = equipe.AjouterJoueurs(joueursToAdd);
Assert.Equal(expectedResult, addedJoueurs.Count);
Assert.All(expectedAddedJoueurs, a => addedJoueurs.Contains(a));
Assert.Equal(expectedJoueurs.Length, equipe.Joueurs.Count);
Assert.All(expectedJoueurs, a => equipe.Joueurs.Contains(a));
}
}
}
params Joueur[] joueursToAdd)
{
var addedJoueurs = equipe.AjouterJoueurs(joueursToAdd);
Assert.Equal(expectedResult, addedJoueurs.Count);
Assert.All(expectedAddedJoueurs, a => addedJoueurs.Contains(a));
Assert.Equal(expectedJoueurs.Length, equipe.Joueurs.Count);
Assert.All(expectedJoueurs, a => equipe.Joueurs.Contains(a));
}
}
}

Loading…
Cancel
Save