ajout test unit add in memory en inline data + modif champ en fact

pull/3/head
Maxence LANONE 2 years ago
parent 175b8398dc
commit 8268a713fd

@ -1,50 +0,0 @@
// <auto-generated />
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
[DbContext(typeof(LolContext))]
[Migration("20230308120111_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.3");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championClass")
.HasColumnType("INTEGER");
b.HasKey("UniqueId");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,37 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
/// <inheritdoc />
public partial class MyMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
UniqueId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
championClass = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.UniqueId);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Champions");
}
}
}

@ -0,0 +1,108 @@
// <auto-generated />
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
[DbContext(typeof(LolContext))]
[Migration("20230317075439_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("SkillType")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImageEntity")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImageEntity");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,82 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
/// <inheritdoc />
public partial class MyMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
UniqueId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Class = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.UniqueId);
});
migrationBuilder.CreateTable(
name: "Skill",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
SkillType = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "LargeImage",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Base64 = table.Column<string>(type: "TEXT", nullable: false),
championId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LargeImage", x => x.Id);
table.ForeignKey(
name: "FK_LargeImage_Champions_championId",
column: x => x.championId,
principalTable: "Champions",
principalColumn: "UniqueId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_LargeImage_championId",
table: "LargeImage",
column: "championId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LargeImage");
migrationBuilder.DropTable(
name: "Skill");
migrationBuilder.DropTable(
name: "Champions");
}
}
}

@ -1,4 +1,5 @@
// <auto-generated />
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -14,7 +15,7 @@ namespace EntityFrameWorkLib.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.3");
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
@ -24,8 +25,12 @@ namespace EntityFrameWorkLib.Migrations
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
@ -34,13 +39,66 @@ namespace EntityFrameWorkLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championClass")
.HasColumnType("INTEGER");
b.HasKey("UniqueId");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("SkillType")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImageEntity")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImageEntity");
});
#pragma warning restore 612, 618
}
}

@ -0,0 +1,20 @@
using System;
namespace EntityFrameWorkLib
{
public class RunePageEntity
{
public int Id { get; set; }
public String Name { get; set; }
}
public enum Category
{
Major,
Minor1,
Minor2,
Minor3,
OtherMinor1,
OtherMinor2
}
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,60 @@
using System;
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
namespace TestUnitaireLOL
{
public class TestsData
{
public IEnumerable<object[]> Data_TestAddItem()
{
yield return new object[]
{
1,
new ChampionEntity[]
{
new ChampionEntity
{
Name = "jax",
Icon = "icon jax",
Bio = "test bio jax",
Class = ChampionClass.Fighter,
LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdefefef"}
},
new ChampionEntity
{
Name = "jax2",
Icon = "icon jax2",
Bio = "test bio jax2",
Class = ChampionClass.Assassin,
LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfefefe"}
},
new ChampionEntity
{
Name = "jax3",
Icon = "icon jax3",
Bio = "test bio jax3",
Class = ChampionClass.Tank,
LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhefef"}
}
},
new ChampionEntity[]
{
new ChampionEntity()
{
Name = "jax4",
Icon = "icon jax4",
Bio = "test bio jax4",
Class = ChampionClass.Marksman,
LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhvfdfdf"}
}
}
};
}
}
}

@ -1,11 +1,30 @@
using System;
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace TestUnitaireLOL
{
public class UnitTestDbDataManager
{
public UnitTestDbDataManager()
{
}
}
public void Test_Data_AddItem(int expectedResult,
IEnumerable<ChampionEntity> expectedChampions,
IEnumerable<ChampionEntity> expectedChampionsAdded,
params ChampionEntity[] championsToAdd)
{
var connexion = new SqliteConnection("DataSource=:memory:");
connexion.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connexion)
.Options;
using (var context = new LolContext())
{
}
}
}
}

@ -11,7 +11,7 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Loading…
Cancel
Save