Test d'ajout dans la table Score qui prend un nombre de points total, l'id d'une Game et l'id d'un Player
continuous-integration/drone/push Build is failing Details

EF
Théo DUPIN 2 years ago
parent 7605976586
commit 078fa26bd4

@ -1,175 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DbConsole.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230320170448_AllMigrations")]
partial class AllMigrations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b =>
{
b.Property<int>("CaseId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("CaseId");
b.ToTable("Case");
});
modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b =>
{
b.Property<int>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<TimeSpan>("Duration")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbPlayers")
.HasColumnType("INTEGER");
b.HasKey("GameId");
b.ToTable("Game");
});
modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b =>
{
b.Property<int>("GrilleId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxChain")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbChains")
.HasColumnType("INTEGER");
b.Property<int>("NbZones")
.HasColumnType("INTEGER");
b.HasKey("GrilleId");
b.ToTable("Grille");
});
modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b =>
{
b.Property<int>("PlayerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxPoints")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbPlayed")
.HasColumnType("INTEGER");
b.Property<int>("NbPoints")
.HasColumnType("INTEGER");
b.Property<int>("NbWin")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("PlayerId");
b.ToTable("Players");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.Property<int>("ScoreId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("NbPoints")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("ScoreId");
b.HasIndex("GameId");
b.HasIndex("PlayerId");
b.ToTable("Score");
});
modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b =>
{
b.Property<int>("TurnId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("DiceValue1")
.HasColumnType("INTEGER");
b.Property<int>("DiceValue2")
.HasColumnType("INTEGER");
b.HasKey("TurnId");
b.ToTable("Turn");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.HasOne("EntityFrameWorkLib.GameEntity", "Game")
.WithMany()
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Game");
b.Navigation("Player");
});
#pragma warning restore 612, 618
}
}
}

@ -1,151 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DbConsole.Migrations
{
/// <inheritdoc />
public partial class AllMigrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Case",
columns: table => new
{
CaseId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Value = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Case", x => x.CaseId);
});
migrationBuilder.CreateTable(
name: "Game",
columns: table => new
{
GameId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Duration = table.Column<TimeSpan>(type: "TEXT", nullable: false),
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
NbPlayers = table.Column<int>(type: "INTEGER", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Game", x => x.GameId);
});
migrationBuilder.CreateTable(
name: "Grille",
columns: table => new
{
GrilleId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NbChains = table.Column<int>(type: "INTEGER", nullable: false),
NbZones = table.Column<int>(type: "INTEGER", nullable: false),
MaxChain = table.Column<int>(type: "INTEGER", nullable: false),
MaxZone = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Grille", x => x.GrilleId);
});
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
NbWin = table.Column<int>(type: "INTEGER", nullable: false),
NbPlayed = table.Column<int>(type: "INTEGER", nullable: false),
MaxZone = table.Column<int>(type: "INTEGER", nullable: false),
MaxPoints = table.Column<int>(type: "INTEGER", nullable: false),
NbPoints = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.PlayerId);
});
migrationBuilder.CreateTable(
name: "Turn",
columns: table => new
{
TurnId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DiceValue1 = table.Column<int>(type: "INTEGER", nullable: false),
DiceValue2 = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Turn", x => x.TurnId);
});
migrationBuilder.CreateTable(
name: "Score",
columns: table => new
{
ScoreId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NbPoints = table.Column<int>(type: "INTEGER", nullable: false),
GameId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Score", x => x.ScoreId);
table.ForeignKey(
name: "FK_Score_Game_GameId",
column: x => x.GameId,
principalTable: "Game",
principalColumn: "GameId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Score_Players_PlayerId",
column: x => x.PlayerId,
principalTable: "Players",
principalColumn: "PlayerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Score_GameId",
table: "Score",
column: "GameId");
migrationBuilder.CreateIndex(
name: "IX_Score_PlayerId",
table: "Score",
column: "PlayerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Case");
migrationBuilder.DropTable(
name: "Grille");
migrationBuilder.DropTable(
name: "Score");
migrationBuilder.DropTable(
name: "Turn");
migrationBuilder.DropTable(
name: "Game");
migrationBuilder.DropTable(
name: "Players");
}
}
}

@ -1,172 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DbConsole.Migrations
{
[DbContext(typeof(SQLiteContext))]
partial class SQLiteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b =>
{
b.Property<int>("CaseId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("CaseId");
b.ToTable("Case");
});
modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b =>
{
b.Property<int>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<TimeSpan>("Duration")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbPlayers")
.HasColumnType("INTEGER");
b.HasKey("GameId");
b.ToTable("Game");
});
modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b =>
{
b.Property<int>("GrilleId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxChain")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbChains")
.HasColumnType("INTEGER");
b.Property<int>("NbZones")
.HasColumnType("INTEGER");
b.HasKey("GrilleId");
b.ToTable("Grille");
});
modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b =>
{
b.Property<int>("PlayerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxPoints")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbPlayed")
.HasColumnType("INTEGER");
b.Property<int>("NbPoints")
.HasColumnType("INTEGER");
b.Property<int>("NbWin")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("PlayerId");
b.ToTable("Players");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.Property<int>("ScoreId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("NbPoints")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("ScoreId");
b.HasIndex("GameId");
b.HasIndex("PlayerId");
b.ToTable("Score");
});
modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b =>
{
b.Property<int>("TurnId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("DiceValue1")
.HasColumnType("INTEGER");
b.Property<int>("DiceValue2")
.HasColumnType("INTEGER");
b.HasKey("TurnId");
b.ToTable("Turn");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.HasOne("EntityFrameWorkLib.GameEntity", "Game")
.WithMany()
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Game");
b.Navigation("Player");
});
#pragma warning restore 612, 618
}
}
}

@ -1,32 +1,21 @@
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Model;
PlayerEntity p1 = new PlayerEntity
{
PlayerId = 0,
Pseudo = "Jax",
NbWin = 0,
NbPlayed = 0,
MaxZone = 0,
MaxPoints = 0,
NbPoints = 0
};
GameEntity g1 = new GameEntity
/*GameEntity g1 = new GameEntity
{
GameId = 1,
};
};*/
PlayerEntity p2 = new PlayerEntity
/*PlayerEntity p1 = new PlayerEntity
{
PlayerId = 0,
Pseudo = "Theo",
PlayerId = 1,
Pseudo = "Jax",
NbWin = 0,
NbPlayed = 0,
MaxZone = 0,
MaxPoints = 0,
NbPoints = 0
};
};*/
/*using (var context = new SQLiteContext())
{
@ -38,14 +27,35 @@ PlayerEntity p2 = new PlayerEntity
using (var context = new SQLiteContext())
{
var newScore = new ScoreEntity
var firstGame = new GameEntity
{
GameId = 1,
Name = "First Game",
};
var secondGame = new GameEntity
{
GameId = 2,
Name = "Second Game",
};
var thirdGame = new GameEntity
{
GameId = 3,
Name = "Third Game",
};
var newPlayer = new PlayerEntity
{
PlayerId = 2,
NbPoints = 5
Pseudo = "Jax"
};
context.Add(newScore);
var scores = new List<ScoreEntity>
{
new ScoreEntity { GameId = 1, NbPointsTotal = 5 },
new ScoreEntity { GameId = 2, NbPointsTotal = 10 },
new ScoreEntity { GameId = 3, NbPointsTotal = 15 }
};
newPlayer.Scores = scores;
context.AddRange(firstGame, secondGame, thirdGame, newPlayer);
context.AddRange(scores);
context.SaveChanges();
}

@ -13,15 +13,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameWorkLib", "Trek1
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbConsole", "Tests\DbConsole\DbConsole.csproj", "{75B303CC-F36E-46FA-BE23-05EEA35D9B28}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelTest", "Tests\ModelTest\ModelTest.csproj", "{6EC6383D-10E8-44E1-8EDD-EF4DF460A9B1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModelTest", "Tests\ModelTest\ModelTest.csproj", "{6EC6383D-10E8-44E1-8EDD-EF4DF460A9B1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{B1585816-FCBB-484F-A1AA-C7AEB501C39B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stub", "Stub\Stub\Stub.csproj", "{5E45E953-4FCC-42B6-9F22-15108D002D78}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stub", "Stub\Stub\Stub.csproj", "{5E45E953-4FCC-42B6-9F22-15108D002D78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{8B6EC777-57F8-4509-9163-4312A40FE63C}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{7DF17583-2166-4ABE-82EE-F63CEE2132C2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{8B6EC777-57F8-4509-9163-4312A40FE63C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -57,10 +55,6 @@ Global
{8B6EC777-57F8-4509-9163-4312A40FE63C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B6EC777-57F8-4509-9163-4312A40FE63C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B6EC777-57F8-4509-9163-4312A40FE63C}.Release|Any CPU.Build.0 = Release|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -17,6 +17,7 @@ namespace EntityFrameWorkLib
public DateOnly Date { get; set; }
public int NbPlayers { get; set; }
public string Name { get; set; }
//public ICollection<PlayerEntity> NbPoints { get; set; }
public List<ScoreEntity> Scores { get; set; }
}
}

@ -14,7 +14,7 @@ namespace EntityFrameWorkLib
public int NbPlayed { get; set; }
public int MaxZone { get; set; }
public int MaxPoints { get; set; }
public int NbPoints { get; set; }
public List<ScoreEntity> Scores { get; set; }
}
}

@ -13,7 +13,7 @@ namespace EntityFrameWorkLib
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ScoreId { get; set; }
public int NbPoints { get; set; }
public int NbPointsTotal { get; set; }
public int GameId { get; set; }
[ForeignKey("GameId")]

@ -55,6 +55,26 @@ namespace EntityFrameWorkLib
modelBuilder.Entity<TurnEntity>().Property(n => n.TurnId).ValueGeneratedOnAdd();
modelBuilder.Entity<ScoreEntity>().Property(n => n.ScoreId).ValueGeneratedOnAdd();
//Configuration des clés primaires et étrangères pour la table Score
modelBuilder.Entity<ScoreEntity>()
.HasKey(s => s.ScoreId);
modelBuilder.Entity<GameEntity>()
.HasKey(g => g.GameId);
modelBuilder.Entity<PlayerEntity>()
.HasKey(p => p.PlayerId);
modelBuilder.Entity<ScoreEntity>()
.HasOne(s => s.Game)
.WithMany(g => g.Scores)
.HasForeignKey(s => s.GameId);
modelBuilder.Entity<ScoreEntity>()
.HasOne(s => s.Player)
.WithMany(p => p.Scores)
.HasForeignKey(s => s.PlayerId);
base.OnModelCreating(modelBuilder);
}
}

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk" DefaultTargets="Build">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>{7DF17583-2166-4ABE-82EE-F63CEE2132C2}</ProjectGuid>
<DockerLaunchBrowser>True</DockerLaunchBrowser>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>trek12_api</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
version: '3.4'
services:
trek12_api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "80"
- "443"
volumes:
- ~/.aspnet/https:/root/.aspnet/https:ro
- ~/.microsoft/usersecrets:/root/.microsoft/usersecrets:ro

@ -0,0 +1,8 @@
version: '3.4'
services:
trek12_api:
image: ${DOCKER_REGISTRY-}trek12api
build:
context: .
dockerfile: Trek12_API/Dockerfile
Loading…
Cancel
Save