fix bd + pb Tests Unit 🐛
continuous-integration/drone/push Build is passing Details

pagination
Tony Fages 1 year ago
parent 80b429936f
commit 739f157fbc

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -39,7 +39,7 @@ app.MapControllers();
using var scoped = app.Services.CreateScope();
var libraryContext = scoped.ServiceProvider.GetService<LibraryContext>();
//libraryContext.Database.EnsureCreated();
//libraryContext.Database.EnsureCreated();
libraryContext.Database.Migrate();
app.Run();

@ -1,89 +0,0 @@
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class StubbedContext : LibraryContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ArticleEntity>().HasData(
new ArticleEntity
{
Id = 1,
Title = "Breaking News Elisabeth 2 Died",
Description = "The queen of England died today at the age of 95",
DatePublished = "2022-02-06",
LectureTime = 2,
Author = "Tom Smith"
},
new ArticleEntity
{
Id = 2,
Title = "The new iPhone 15",
Description = "The new iPhone 15 is out and it's the best phone ever",
DatePublished = "2022-02-06",
LectureTime = 3,
Author = "Tom Smith"
},
new ArticleEntity
{
Id = 3,
Title = "M&M's new recipe",
Description = "M&M's new recipe is out and it's the best chocolate ever",
DatePublished = "2022-02-06",
LectureTime = 1,
Author = "M&M's Red"
}
);
modelBuilder.Entity<UserEntity>().HasData(
new UserEntity
{
Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
},
new UserEntity
{
Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234",
Role = "User"
},
new UserEntity
{
Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
}
);
modelBuilder.Entity<ArticleUserEntity>().HasData(
new ArticleUserEntity
{
ArticleEntityId = 1,
UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
UserEntityPseudo = "Sha"
}
);
}
}

@ -51,7 +51,6 @@ public class LibraryContext : DbContext
.HasOne(f => f.User)
.WithMany(u => u.Forms)
.HasForeignKey(f => f.UserEntityPseudo);
/*
modelBuilder.Entity<ArticleEntity>().HasData(
new ArticleEntity

@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DbContextLib.Migrations
{
[DbContext(typeof(LibraryContext))]
[Migration("20240311132206_mrg1")]
[Migration("20240312155559_mrg1")]
partial class mrg1
{
/// <inheritdoc />
@ -83,12 +83,12 @@ namespace DbContextLib.Migrations
b.Property<long>("ArticleEntityId")
.HasColumnType("INTEGER");
b.Property<long>("UserEntityId")
.HasColumnType("INTEGER");
b.Property<string>("UserEntityPseudo")
.HasColumnType("TEXT");
b.HasKey("ArticleEntityId", "UserEntityId");
b.HasKey("ArticleEntityId", "UserEntityPseudo");
b.HasIndex("UserEntityId");
b.HasIndex("UserEntityPseudo");
b.ToTable("ArticleUserSet");
@ -96,27 +96,27 @@ namespace DbContextLib.Migrations
new
{
ArticleEntityId = 1L,
UserEntityId = 1L
UserEntityPseudo = "TonyF"
},
new
{
ArticleEntityId = 2L,
UserEntityId = 2L
UserEntityPseudo = "NoaSil"
},
new
{
ArticleEntityId = 3L,
UserEntityId = 3L
UserEntityPseudo = "Sha"
},
new
{
ArticleEntityId = 3L,
UserEntityId = 1L
UserEntityPseudo = "RedM"
},
new
{
ArticleEntityId = 2L,
UserEntityId = 3L
UserEntityPseudo = "TomS"
});
});
@ -134,20 +134,17 @@ namespace DbContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
b.Property<string>("Theme")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Theme")
b.Property<string>("UserEntityPseudo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("UserEntityId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("UserEntityId");
b.HasIndex("UserEntityPseudo");
b.ToTable("FormSet");
@ -157,35 +154,31 @@ namespace DbContextLib.Migrations
Id = 1L,
DatePublication = "Form 1 Description",
Link = "hhtp://form1.com",
Pseudo = "Form 1",
Theme = "",
UserEntityId = 1L
UserEntityPseudo = "Sha"
},
new
{
Id = 2L,
DatePublication = "Form 2 Description",
Link = "hhtp://form2.com",
Pseudo = "Form 2",
Theme = "",
UserEntityId = 2L
UserEntityPseudo = "Sha"
},
new
{
Id = 3L,
DatePublication = "Form 3 Description",
Link = "hhtp://form3.com",
Pseudo = "Form 3",
Theme = "",
UserEntityId = 3L
UserEntityPseudo = "Sha"
});
});
modelBuilder.Entity("Entities.UserEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.HasColumnType("TEXT");
b.Property<string>("Mail")
.IsRequired()
@ -203,67 +196,58 @@ namespace DbContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasKey("Pseudo");
b.ToTable("UserSet");
b.HasData(
new
{
Id = 1L,
Pseudo = "TonyF",
Mail = "tony@gmail.com",
Mdp = "1234",
Nom = "Fages",
Prenom = "Tony",
Pseudo = "TonyF",
Role = "Admin"
},
new
{
Id = 2L,
Pseudo = "TomS",
Mail = "tom@mail.com",
Mdp = "1234",
Nom = "Smith",
Prenom = "Tom",
Pseudo = "TomS",
Role = "User"
},
new
{
Id = 3L,
Pseudo = "RedM",
Mail = "M&M#mail.com",
Mdp = "1234",
Nom = "M&M's",
Prenom = "Red",
Pseudo = "RedM",
Role = "Modérator"
},
new
{
Id = 4L,
Pseudo = "Sha",
Mail = "ShaCasca@gmail.com",
Mdp = "1234",
Nom = "Cascarra",
Prenom = "Cascarra",
Pseudo = "Sha",
Role = "Admin"
},
new
{
Id = 5L,
Pseudo = "NoaSil",
Mail = "",
Mdp = "1234",
Nom = "Sillard",
Prenom = "Noa",
Pseudo = "NoaSil",
Role = "Admin"
});
});
@ -278,7 +262,7 @@ namespace DbContextLib.Migrations
b.HasOne("Entities.UserEntity", null)
.WithMany()
.HasForeignKey("UserEntityId")
.HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
@ -287,7 +271,7 @@ namespace DbContextLib.Migrations
{
b.HasOne("Entities.UserEntity", "User")
.WithMany("Forms")
.HasForeignKey("UserEntityId")
.HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

@ -33,8 +33,6 @@ namespace DbContextLib.Migrations
name: "UserSet",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
Mdp = table.Column<string>(type: "TEXT", nullable: false),
Nom = table.Column<string>(type: "TEXT", nullable: false),
@ -44,19 +42,19 @@ namespace DbContextLib.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_UserSet", x => x.Id);
table.PrimaryKey("PK_UserSet", x => x.Pseudo);
});
migrationBuilder.CreateTable(
name: "ArticleUserSet",
columns: table => new
{
UserEntityId = table.Column<long>(type: "INTEGER", nullable: false),
UserEntityPseudo = table.Column<string>(type: "TEXT", nullable: false),
ArticleEntityId = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArticleUserSet", x => new { x.ArticleEntityId, x.UserEntityId });
table.PrimaryKey("PK_ArticleUserSet", x => new { x.ArticleEntityId, x.UserEntityPseudo });
table.ForeignKey(
name: "FK_ArticleUserSet_ArticleSet_ArticleEntityId",
column: x => x.ArticleEntityId,
@ -64,10 +62,10 @@ namespace DbContextLib.Migrations
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ArticleUserSet_UserSet_UserEntityId",
column: x => x.UserEntityId,
name: "FK_ArticleUserSet_UserSet_UserEntityPseudo",
column: x => x.UserEntityPseudo,
principalTable: "UserSet",
principalColumn: "Id",
principalColumn: "Pseudo",
onDelete: ReferentialAction.Cascade);
});
@ -80,17 +78,16 @@ namespace DbContextLib.Migrations
Theme = table.Column<string>(type: "TEXT", nullable: false),
DatePublication = table.Column<string>(type: "TEXT", nullable: false),
Link = table.Column<string>(type: "TEXT", nullable: false),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
UserEntityId = table.Column<long>(type: "INTEGER", nullable: false)
UserEntityPseudo = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FormSet", x => x.Id);
table.ForeignKey(
name: "FK_FormSet_UserSet_UserEntityId",
column: x => x.UserEntityId,
name: "FK_FormSet_UserSet_UserEntityPseudo",
column: x => x.UserEntityPseudo,
principalTable: "UserSet",
principalColumn: "Id",
principalColumn: "Pseudo",
onDelete: ReferentialAction.Cascade);
});
@ -106,47 +103,47 @@ namespace DbContextLib.Migrations
migrationBuilder.InsertData(
table: "UserSet",
columns: new[] { "Id", "Mail", "Mdp", "Nom", "Prenom", "Pseudo", "Role" },
columns: new[] { "Pseudo", "Mail", "Mdp", "Nom", "Prenom", "Role" },
values: new object[,]
{
{ 1L, "tony@gmail.com", "1234", "Fages", "Tony", "TonyF", "Admin" },
{ 2L, "tom@mail.com", "1234", "Smith", "Tom", "TomS", "User" },
{ 3L, "M&M#mail.com", "1234", "M&M's", "Red", "RedM", "Modérator" },
{ 4L, "ShaCasca@gmail.com", "1234", "Cascarra", "Cascarra", "Sha", "Admin" },
{ 5L, "", "1234", "Sillard", "Noa", "NoaSil", "Admin" }
{ "NoaSil", "", "1234", "Sillard", "Noa", "Admin" },
{ "RedM", "M&M#mail.com", "1234", "M&M's", "Red", "Modérator" },
{ "Sha", "ShaCasca@gmail.com", "1234", "Cascarra", "Cascarra", "Admin" },
{ "TomS", "tom@mail.com", "1234", "Smith", "Tom", "User" },
{ "TonyF", "tony@gmail.com", "1234", "Fages", "Tony", "Admin" }
});
migrationBuilder.InsertData(
table: "ArticleUserSet",
columns: new[] { "ArticleEntityId", "UserEntityId" },
columns: new[] { "ArticleEntityId", "UserEntityPseudo" },
values: new object[,]
{
{ 1L, 1L },
{ 2L, 2L },
{ 2L, 3L },
{ 3L, 1L },
{ 3L, 3L }
{ 1L, "TonyF" },
{ 2L, "NoaSil" },
{ 2L, "TomS" },
{ 3L, "RedM" },
{ 3L, "Sha" }
});
migrationBuilder.InsertData(
table: "FormSet",
columns: new[] { "Id", "DatePublication", "Link", "Pseudo", "Theme", "UserEntityId" },
columns: new[] { "Id", "DatePublication", "Link", "Theme", "UserEntityPseudo" },
values: new object[,]
{
{ 1L, "Form 1 Description", "hhtp://form1.com", "Form 1", "", 1L },
{ 2L, "Form 2 Description", "hhtp://form2.com", "Form 2", "", 2L },
{ 3L, "Form 3 Description", "hhtp://form3.com", "Form 3", "", 3L }
{ 1L, "Form 1 Description", "hhtp://form1.com", "", "Sha" },
{ 2L, "Form 2 Description", "hhtp://form2.com", "", "Sha" },
{ 3L, "Form 3 Description", "hhtp://form3.com", "", "Sha" }
});
migrationBuilder.CreateIndex(
name: "IX_ArticleUserSet_UserEntityId",
name: "IX_ArticleUserSet_UserEntityPseudo",
table: "ArticleUserSet",
column: "UserEntityId");
column: "UserEntityPseudo");
migrationBuilder.CreateIndex(
name: "IX_FormSet_UserEntityId",
name: "IX_FormSet_UserEntityPseudo",
table: "FormSet",
column: "UserEntityId");
column: "UserEntityPseudo");
}
/// <inheritdoc />

@ -80,12 +80,12 @@ namespace DbContextLib.Migrations
b.Property<long>("ArticleEntityId")
.HasColumnType("INTEGER");
b.Property<long>("UserEntityId")
.HasColumnType("INTEGER");
b.Property<string>("UserEntityPseudo")
.HasColumnType("TEXT");
b.HasKey("ArticleEntityId", "UserEntityId");
b.HasKey("ArticleEntityId", "UserEntityPseudo");
b.HasIndex("UserEntityId");
b.HasIndex("UserEntityPseudo");
b.ToTable("ArticleUserSet");
@ -93,27 +93,27 @@ namespace DbContextLib.Migrations
new
{
ArticleEntityId = 1L,
UserEntityId = 1L
UserEntityPseudo = "TonyF"
},
new
{
ArticleEntityId = 2L,
UserEntityId = 2L
UserEntityPseudo = "NoaSil"
},
new
{
ArticleEntityId = 3L,
UserEntityId = 3L
UserEntityPseudo = "Sha"
},
new
{
ArticleEntityId = 3L,
UserEntityId = 1L
UserEntityPseudo = "RedM"
},
new
{
ArticleEntityId = 2L,
UserEntityId = 3L
UserEntityPseudo = "TomS"
});
});
@ -131,20 +131,17 @@ namespace DbContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
b.Property<string>("Theme")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Theme")
b.Property<string>("UserEntityPseudo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("UserEntityId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("UserEntityId");
b.HasIndex("UserEntityPseudo");
b.ToTable("FormSet");
@ -154,35 +151,31 @@ namespace DbContextLib.Migrations
Id = 1L,
DatePublication = "Form 1 Description",
Link = "hhtp://form1.com",
Pseudo = "Form 1",
Theme = "",
UserEntityId = 1L
UserEntityPseudo = "Sha"
},
new
{
Id = 2L,
DatePublication = "Form 2 Description",
Link = "hhtp://form2.com",
Pseudo = "Form 2",
Theme = "",
UserEntityId = 2L
UserEntityPseudo = "Sha"
},
new
{
Id = 3L,
DatePublication = "Form 3 Description",
Link = "hhtp://form3.com",
Pseudo = "Form 3",
Theme = "",
UserEntityId = 3L
UserEntityPseudo = "Sha"
});
});
modelBuilder.Entity("Entities.UserEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.HasColumnType("TEXT");
b.Property<string>("Mail")
.IsRequired()
@ -200,67 +193,58 @@ namespace DbContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasKey("Pseudo");
b.ToTable("UserSet");
b.HasData(
new
{
Id = 1L,
Pseudo = "TonyF",
Mail = "tony@gmail.com",
Mdp = "1234",
Nom = "Fages",
Prenom = "Tony",
Pseudo = "TonyF",
Role = "Admin"
},
new
{
Id = 2L,
Pseudo = "TomS",
Mail = "tom@mail.com",
Mdp = "1234",
Nom = "Smith",
Prenom = "Tom",
Pseudo = "TomS",
Role = "User"
},
new
{
Id = 3L,
Pseudo = "RedM",
Mail = "M&M#mail.com",
Mdp = "1234",
Nom = "M&M's",
Prenom = "Red",
Pseudo = "RedM",
Role = "Modérator"
},
new
{
Id = 4L,
Pseudo = "Sha",
Mail = "ShaCasca@gmail.com",
Mdp = "1234",
Nom = "Cascarra",
Prenom = "Cascarra",
Pseudo = "Sha",
Role = "Admin"
},
new
{
Id = 5L,
Pseudo = "NoaSil",
Mail = "",
Mdp = "1234",
Nom = "Sillard",
Prenom = "Noa",
Pseudo = "NoaSil",
Role = "Admin"
});
});
@ -275,7 +259,7 @@ namespace DbContextLib.Migrations
b.HasOne("Entities.UserEntity", null)
.WithMany()
.HasForeignKey("UserEntityId")
.HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
@ -284,7 +268,7 @@ namespace DbContextLib.Migrations
{
b.HasOne("Entities.UserEntity", "User")
.WithMany("Forms")
.HasForeignKey("UserEntityId")
.HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

Loading…
Cancel
Save