Compare commits

...

9 Commits

Author SHA1 Message Date
Lucas DELANIER d61badd2c1 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 43e79ad879 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 30006c2a05 merge EF master
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 9d5bb44db7 merge EF
2 years ago
Louison PARANT 954a5beaf4 merge
2 years ago
Louison PARANT 931860ad0e Push EFManager
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 360c84ed35 Finished DB
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT e071376f80 Add Entities and EFManagers
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 17718682ad Fusion EFManager
2 years ago

@ -22,7 +22,7 @@ Merci de noter la v1 de l'api qui est tenu a jour la v2 sert uniquement a montre
Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android grâce à l'outil Android Studio ou grâce à un émulateur Android. Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android grâce à l'outil Android Studio ou grâce à un émulateur Android.
## Archutecture ## Architecture
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Schema_architecture.png) ![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Schema_architecture.png)
Ce schéma d'architecure globale permet de comprendre la composition interne de la solution. Ce schéma d'architecure globale permet de comprendre la composition interne de la solution.
@ -56,14 +56,18 @@ Ci dessus on voit que l'object champion a une nouvelle "forme" ChampionDTO que l
## 4 - Lien entre API et Entityframework ## 4 - Lien entre API et Entityframework
... Pour relier l'API avec la partie EntityFramework, cela se passe du côté de l'API. En effet, en ayant implémenter des managers en EntityFramework, il suffit de les instancier côté API puis de demander la requête adéquate pour obtenir les données de la base de données avec l'API. Ces managers regroupent plusieurs petits managers gérant chacun une entité de la base de données (Champion, RunePage, Rune, ...). Il n'y a pas de managers de Skill car ceux-ci sont compris dans le manager Champion (un peu comme les mappers côté API).
## 5 - Mappage des classes métier en tables ## 5 - Mappage des classes métier en tables
... Afin de rentrer les classes métiers en base de données, il faut avant tout les mapper. Ainsi, il y a un mapper pour chaque entité de la base de données (même pour Skill par exemple). Ensuite, il faut deux méthodes pour chaque mapper :
<br> 1- ToEntity : elle prend en paramètre un objet du modèle et permet de le transformer en entité afin de pouvoir l'insérer en base de données.
<br> 2- ToModel : elle prend en paramètre une entité et permet de la transformer en objet.
Grâce à ces deux méthodes, nous pouvons facilement mapper des entités en objet et inversement.
## 6 - Lien avec base de données SQLlite ## 6 - Lien avec base de données SQLite
... Il y a deux manières d'utiliser la base de données SQLite. On peut soit, utiliser la base de données interne à l'appareil ou bien utiliser la mémoire de l'appareil pour sauvegarder les données en local. Pour créer la base, il faut avoir des classes entités représentant chacune une table de la base. Il peut aussi y avoir des entités représentant des liaisons entre deux tables (RunePageRuneEntity par exemple représente la table entre RunePage et Rune). Ensuite, il faut un contexte (SQLiteContext pour notre projet) qui a pour attributs des DbSets, des listes d'entités à mettre en base de données. Pour remplir la base de données, avec un Stub par exemple, on peut utiliser la méthode onCreate du contexte pour insérer des entités créees manuellement. Cependant, pour mettre des objets en base, il faut donc les mapper en entité puis, passer par un manager (dans notre cas) pour enfin le rentrer en base.
## :wrench: SUPPORT ## :wrench: SUPPORT

@ -19,6 +19,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.Core" Version="5.6.0" /> <PackageReference Include="Swashbuckle.Core" Version="5.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,71 @@
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ChampionsController : ControllerBase
{
IChampionsManager dataManager;
public ChampionsController(IDataManager dataManager)
{
this.dataManager = dataManager.ChampionsMgr;
}
// GET: api/<ChampionController>
[HttpGet]
public async Task<IActionResult> Get(int index, int count)
{
var champions = await dataManager.GetItems(index, count);
IEnumerable<ChampionDTO> items = champions.Select(c => c.ToDto());
return Ok(items);
}
// GET api/<ChampionController>/5
[HttpGet("{name}")]
public async Task<IActionResult> Get(string name)
{
if (dataManager.GetNbItemsByName(name) != null)
{
return Ok(dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
}
return NotFound();
}
// POST api/<ChampionController>
[HttpPost]
public async Task<IActionResult> Post([FromBody] ChampionDTO championDTO)
{
return CreatedAtAction(nameof(Get),(await dataManager.AddItem(championDTO.ToModel())).ToDto);
}
// PUT api/<ChampionController>/5
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] ChampionDTO championDTO)
{
var dtos = (await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
return Ok(dataManager.UpdateItem(dtos.First(), championDTO.ToModel()));
}
// DELETE api/<ChampionController>/5
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
var dtos = (await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
return Ok(dataManager.DeleteItem(dtos.First()));
}
}
}

@ -1,4 +1,5 @@
using DTO; using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities; using EntityFrameworkLOL.Entities;
using Model; using Model;
@ -24,21 +25,31 @@ namespace APILOL.Mapper
return new Champion(champion.Name, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio); return new Champion(champion.Name, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio);
} }
public static ChampionEntity ToEntity(this Champion item) public static Champion ToModel(this ChampionEntity entity)
{ {
return new() var champion = new Champion(entity.Name, entity.Class, entity.Icon, "", entity.Bio);
{ if (entity.Skills != null) foreach (var s in entity.Skills) { champion.AddSkill(s.ToModel()); }
Name = item.Name, if (entity.Characteristics != null) foreach (var c in entity.Characteristics) { champion.AddCharacteristics(c.ToModel()); }
Bio = item.Bio, return champion;
Icon = item.Icon,
Class = item.Class,
Image = new() { Base64 = item.Image.Base64 },
};
} }
public static Champion ToModel(this ChampionEntity entity) public static ChampionEntity ToEntity(this Champion item, SQLiteContext context)
{ {
return new(entity.Name, entity.Class, entity.Icon, entity.Image.Base64, entity.Bio); ChampionEntity? championEntity = context.Champion.Find(item.Name);
if (championEntity == null)
{
championEntity = new()
{
Name = item.Name,
Bio = item.Bio,
Icon = item.Icon,
Class = item.Class,
Image = new() { Base64 = item.Image.Base64 },
};
championEntity.Skills = item.Skills.Select(x => x.ToEntity(championEntity, context)).ToList();
championEntity.Characteristics = item.Characteristics.Select(x => x.ToEntity(championEntity, context)).ToList();
}
return championEntity;
} }
} }
} }

@ -0,0 +1,26 @@
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
namespace APILOL.Mapper
{
public static class CharacteristicsMapper
{
public static CharacteristicEntity ToEntity(this KeyValuePair<string, int> item, ChampionEntity champion, SQLiteContext context)
{
var characteristicEntity = context.Characteristic.Find(item.Key, champion.Name);
if (characteristicEntity == null)
{
return new()
{
Name = item.Key,
Value = item.Value,
};
}
return characteristicEntity;
}
public static Tuple<string, int> ToModel(this CharacteristicEntity entity)
=> new(entity.Name, entity.Value);
}
}

@ -1,4 +1,6 @@
using DTO; using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model; using Model;
namespace APILOL.Mapper namespace APILOL.Mapper
@ -20,5 +22,25 @@ namespace APILOL.Mapper
{ {
return new Rune(rune.Name, rune.Family, rune.Image, rune.Image, rune.Description); return new Rune(rune.Name, rune.Family, rune.Image, rune.Image, rune.Description);
} }
public static Rune ToModel(this RuneEntity entity)
{
return new Rune(entity.Name, entity.Family, "", entity.Image.Base64, entity.Description);
}
public static RuneEntity ToEntity(this Rune item, SQLiteContext context)
{
RuneEntity? runeEntity = context.Rune.Find(item.Name);
if (runeEntity == null)
{
return new()
{
Name = item.Name,
Description = item.Description,
Family = item.Family
};
}
return runeEntity;
}
} }
} }

@ -1,4 +1,6 @@
using DTO; using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model; using Model;
namespace APILOL.Mapper namespace APILOL.Mapper
@ -18,5 +20,37 @@ namespace APILOL.Mapper
{ {
return new RunePage(runePage.Name); return new RunePage(runePage.Name);
} }
public static RunePage ToModel(this RunePageEntity entity, SQLiteContext context)
{
RunePage runePage = new(entity.Name);
if (entity.Runes != null)
{
foreach (var r in entity.Runes)
{
var rune = context.Rune.Find(r.Name);
//if (rune != null) runePage[r.category] = rune.ToModel();
};
}
return runePage;
}
public static RunePageEntity ToEntity(this RunePage item, SQLiteContext context)
{
RunePageEntity? runePageEntity = context.RunePage.Find(item.Name);
if (runePageEntity == null)
{
runePageEntity = new()
{
Name = item.Name,
};
runePageEntity.Runes = new List<RuneEntity>();
foreach (var r in item.Runes)
{
runePageEntity.Runes.Add(r.Value.ToEntity(context));
}
}
return runePageEntity;
}
} }
} }

@ -1,17 +1,40 @@
using DTO; using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model; using Model;
namespace APILOL.Mapper namespace APILOL.Mapper
{ {
public static class SkillMapper public static class SkillMapper
{ {
public static SkillEntity ToEntity(this Skill item, ChampionEntity champion, SQLiteContext context)
{
var skillEntity = context.Skill.Find(item.Name);
if (skillEntity == null)
{
return new()
{
Name = item.Name,
Description = item.Description,
Type = item.Type,
Champions = new List<ChampionEntity>() { champion }
};
}
skillEntity!.Champions?.Add(champion);
return skillEntity;
}
public static Skill ToModel(this SkillEntity entity)
=> new(entity.Name, entity.Type, entity.Description);
public static SkillDTO ToDto(this Skill skill) public static SkillDTO ToDto(this Skill skill)
{ {
return new SkillDTO() return new SkillDTO()
{ {
Type = skill.Type, Type = skill.Type,
Name = skill.Name, Name = skill.Name,
Description = skill.Description Description = skill.Description
}; };
} }

@ -1,4 +1,6 @@
using DTO; using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model; using Model;
namespace APILOL.Mapper namespace APILOL.Mapper
@ -22,5 +24,23 @@ namespace APILOL.Mapper
{ {
return new Skin(skin.Name, skin.Champion.ToModel(),skin.Price, skin.Image, skin.Icon, skin.Description); return new Skin(skin.Name, skin.Champion.ToModel(),skin.Price, skin.Image, skin.Icon, skin.Description);
} }
public static Skin ToModel(this SkinEntity entity)
{
return new Skin(entity.Name, entity.ChampionSkin.ToModel(), entity.Price, entity.Icon, entity.Description);
}
public static SkinEntity ToEntity(this Skin item, SQLiteContext? context = null)
{
return new()
{
Name = item.Name,
ChampionSkin = context?.Champion.Find(item.Champion.Name) ?? item.Champion.ToEntity(context),
Description = item.Description,
Icon = item.Icon,
Image = null,
Price = item.Price
};
}
} }
} }

@ -14,6 +14,8 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -1,5 +1,7 @@
using EntityFrameworkLOL.Entities; using EntityFrameworkLOL.Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Model; using Model;
namespace EntityFrameworkLOL.DBContexts namespace EntityFrameworkLOL.DBContexts
@ -11,20 +13,30 @@ namespace EntityFrameworkLOL.DBContexts
public DbSet<SkinEntity> Skin { get; set; } public DbSet<SkinEntity> Skin { get; set; }
public DbSet<RuneEntity> Rune { get; set; } public DbSet<RuneEntity> Rune { get; set; }
public DbSet<RunePageEntity> RunePage { get; set; } public DbSet<RunePageEntity> RunePage { get; set; }
public DbSet<CharacteristicEntity> Characteristic { get; set; }
public DbSet<ChampionEntity> Champion { get; set; } public DbSet<ChampionEntity> Champion { get; set; }
public SQLiteContext() { }
public SQLiteContext(DbContextOptions<SQLiteContext> options)
: base(options)
{ }
protected override void OnConfiguring(DbContextOptionsBuilder options) protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db"); {
//var connection = new SqliteConnection("DataSource=:memory:");
var connection = new SqliteConnection("Data Source=DBLOL.db");
connection.Open();
options.UseSqlite(connection);
}
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<ImageEntity>().Property(i => i.Base64).ValueGeneratedOnAdd(); modelBuilder.Entity<ImageEntity>().Property(i => i.Base64).ValueGeneratedOnAdd();
modelBuilder.Entity<CharacteristicEntity>().HasKey(c => new { c.Name, c.Champion }); modelBuilder.Entity<CharacteristicEntity>().HasKey(c => new { c.Name });
modelBuilder.Entity<RunePageEntity>().Property(rp => rp.Name).ValueGeneratedOnAdd(); modelBuilder.Entity<RunePageEntity>().Property(rp => rp.Name).ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>() modelBuilder.Entity<RunePageEntity>()
.HasMany(rp => rp.Runes) .HasMany(rp => rp.Runes);
.WithMany(r => r.RunePages)
.UsingEntity<RunePageRuneEntity>();
modelBuilder.Entity<ChampionEntity>() modelBuilder.Entity<ChampionEntity>()
.HasMany(c => c.RunePages) .HasMany(c => c.RunePages)
.WithMany(rp => rp.Champions); .WithMany(rp => rp.Champions);
@ -41,13 +53,14 @@ namespace EntityFrameworkLOL.DBContexts
Name = "WinKer", Name = "WinKer",
Bio = "Best front-end designer", Bio = "Best front-end designer",
Class = ChampionClass.Mage, Class = ChampionClass.Mage,
Icon = "",
}, },
new() new()
{ {
Name = "Jonquille", Name = "Jonquille",
Bio = "Daffodil", Bio = "Daffodil",
Class = ChampionClass.Support, Class = ChampionClass.Support,
Icon = "",
} }
}); });
modelBuilder.Entity<CharacteristicEntity>().HasData(new List<CharacteristicEntity>() { modelBuilder.Entity<CharacteristicEntity>().HasData(new List<CharacteristicEntity>() {

@ -12,6 +12,7 @@ using Model;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable; using System.Reflection.PortableExecutable;
using System.Security.Claims; using System.Security.Claims;
using EntityFrameworkLOL.Entities;
namespace EntityFrameworkLOL.Entities namespace EntityFrameworkLOL.Entities
{ {
@ -23,17 +24,17 @@ namespace EntityFrameworkLOL.Entities
[Required] [Required]
public string Bio { get; set; } public string Bio { get; set; }
public string Icon { get; set; } public string? Icon { get; set; }
[Required] [Required]
public ChampionClass Class { get; set; } public ChampionClass Class { get; set; }
public ImageEntity Image { get; set; } public ImageEntity? Image { get; set; }
public virtual ICollection<SkillEntity> Skills { get; set; } public virtual ICollection<SkillEntity> Skills { get; set; }
public virtual ICollection<CharacteristicEntity> Characteristics { get; set; } public virtual ICollection<CharacteristicEntity> Characteristics { get; set; }
public ICollection<RunePageEntity> RunePages { get; set; } public virtual ICollection<RunePageEntity> RunePages { get; set; }
} }
} }

@ -17,7 +17,8 @@ namespace EntityFrameworkLOL.Entities
[Required] [Required]
public int Value { get; set; } public int Value { get; set; }
[ForeignKey("ChampionEntity")]
public ChampionEntity Champion { get; set; } public ChampionEntity Champion { get; set; }
//public virtual ICollection<ChampionEntity> Champions { get; set; }
} }
} }

@ -21,6 +21,6 @@ namespace EntityFrameworkLOL.Entities
[Required] [Required]
public RuneFamily Family { get; set; } public RuneFamily Family { get; set; }
public ICollection<RunePageEntity> RunePages { get; set; } public virtual ICollection<RunePageEntity> RunePages { get; set; }
} }
} }

@ -20,8 +20,8 @@ namespace EntityFrameworkLOL.Entities
[Key] [Key]
public string Name { get; set; } public string Name { get; set; }
public ICollection<RuneEntity> Runes { get; set; } public virtual ICollection<RuneEntity> Runes { get; set; }
public ICollection<ChampionEntity> Champions { get; set; } public virtual ICollection<ChampionEntity> Champions { get; set; }
} }
} }

@ -11,5 +11,9 @@ namespace EntityFrameworkLOL.Entities
public class RunePageRuneEntity public class RunePageRuneEntity
{ {
public Category Category { get; set; } public Category Category { get; set; }
public RuneEntity Rune { get; set; }
public RunePageEntity RunePage { get; set; }
} }
} }

@ -15,7 +15,7 @@ namespace EntityFrameworkLOL.Entities
public string Description { get; set; } public string Description { get; set; }
public string Icon { get; set; } public string? Icon { get; set; }
public float Price { get; set; } public float Price { get; set; }

@ -19,6 +19,8 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,374 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230315161305_MigrationWallah6")]
partial class MigrationWallah6
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "RunePagesName");
b.HasIndex("RunePagesName");
b.ToTable("ChampionEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
b.HasData(
new
{
Name = "WinKer",
Bio = "Best front-end designer",
Class = 3,
Icon = ""
},
new
{
Name = "Jonquille",
Bio = "Daffodil",
Class = 5,
Icon = ""
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionName")
.HasColumnType("TEXT");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionName");
b.ToTable("Characteristic");
b.HasData(
new
{
Name = "Front-end",
Value = 100
},
new
{
Name = "Back-end",
Value = 100
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
b.HasData(
new
{
Base64 = "default"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Rune");
b.HasData(
new
{
Name = "Mastering of Blue",
Description = "Blue shades",
Family = 2
},
new
{
Name = "Empty Shards",
Description = "Remove runes",
Family = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
b.HasData(
new
{
Name = "FirstRunepage"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
b.HasData(
new
{
Name = "Beautiful layout",
Description = "Bowl'In",
Type = 3
},
new
{
Name = "DB Support",
Description = "DB",
Type = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
b.HasData(
new
{
Name = "Darker WinKer",
Description = "Be invisible in the darkness but never alone",
Icon = "default",
Price = 9.99f
},
new
{
Name = "Summer Daffodil",
Description = "A jewel of Summer for all year long",
Icon = "default",
Price = 9.99f
});
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.Property<string>("RunesName")
.HasColumnType("TEXT");
b.HasKey("RunePagesName", "RunesName");
b.HasIndex("RunesName");
b.ToTable("RuneEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion")
.WithMany()
.HasForeignKey("ChampionName");
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null)
.WithMany()
.HasForeignKey("RunesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,335 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah6 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Image",
columns: table => new
{
Base64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Image", x => x.Base64);
});
migrationBuilder.CreateTable(
name: "RunePage",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RunePage", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Skill",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Champion",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: true),
Class = table.Column<int>(type: "INTEGER", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Champion", x => x.Name);
table.ForeignKey(
name: "FK_Champion_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "Rune",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
Family = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rune", x => x.Name);
table.ForeignKey(
name: "FK_Rune_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "ChampionEntityRunePageEntity",
columns: table => new
{
ChampionsName = table.Column<string>(type: "TEXT", nullable: false),
RunePagesName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionsName, x.RunePagesName });
table.ForeignKey(
name: "FK_ChampionEntityRunePageEntity_Champion_ChampionsName",
column: x => x.ChampionsName,
principalTable: "Champion",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChampionEntityRunePageEntity_RunePage_RunePagesName",
column: x => x.RunePagesName,
principalTable: "RunePage",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ChampionEntitySkillEntity",
columns: table => new
{
ChampionsName = table.Column<string>(type: "TEXT", nullable: false),
SkillsName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName });
table.ForeignKey(
name: "FK_ChampionEntitySkillEntity_Champion_ChampionsName",
column: x => x.ChampionsName,
principalTable: "Champion",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChampionEntitySkillEntity_Skill_SkillsName",
column: x => x.SkillsName,
principalTable: "Skill",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Characteristic",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Value = table.Column<int>(type: "INTEGER", nullable: false),
ChampionName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Characteristic", x => x.Name);
table.ForeignKey(
name: "FK_Characteristic_Champion_ChampionName",
column: x => x.ChampionName,
principalTable: "Champion",
principalColumn: "Name");
});
migrationBuilder.CreateTable(
name: "Skin",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: true),
Price = table.Column<float>(type: "REAL", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
ChampionSkinName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Skin", x => x.Name);
table.ForeignKey(
name: "FK_Skin_Champion_ChampionSkinName",
column: x => x.ChampionSkinName,
principalTable: "Champion",
principalColumn: "Name");
table.ForeignKey(
name: "FK_Skin_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "RuneEntityRunePageEntity",
columns: table => new
{
RunePagesName = table.Column<string>(type: "TEXT", nullable: false),
RunesName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RuneEntityRunePageEntity", x => new { x.RunePagesName, x.RunesName });
table.ForeignKey(
name: "FK_RuneEntityRunePageEntity_RunePage_RunePagesName",
column: x => x.RunePagesName,
principalTable: "RunePage",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RuneEntityRunePageEntity_Rune_RunesName",
column: x => x.RunesName,
principalTable: "Rune",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Champion",
columns: new[] { "Name", "Bio", "Class", "Icon", "ImageBase64" },
values: new object[,]
{
{ "Jonquille", "Daffodil", 5, "", null },
{ "WinKer", "Best front-end designer", 3, "", null }
});
migrationBuilder.InsertData(
table: "Characteristic",
columns: new[] { "Name", "ChampionName", "Value" },
values: new object[,]
{
{ "Back-end", null, 100 },
{ "Front-end", null, 100 }
});
migrationBuilder.InsertData(
table: "Image",
column: "Base64",
value: "default");
migrationBuilder.InsertData(
table: "Rune",
columns: new[] { "Name", "Description", "Family", "ImageBase64" },
values: new object[,]
{
{ "Empty Shards", "Remove runes", 1, null },
{ "Mastering of Blue", "Blue shades", 2, null }
});
migrationBuilder.InsertData(
table: "RunePage",
column: "Name",
value: "FirstRunepage");
migrationBuilder.InsertData(
table: "Skill",
columns: new[] { "Name", "Description", "Type" },
values: new object[,]
{
{ "Beautiful layout", "Bowl'In", 3 },
{ "DB Support", "DB", 1 }
});
migrationBuilder.InsertData(
table: "Skin",
columns: new[] { "Name", "ChampionSkinName", "Description", "Icon", "ImageBase64", "Price" },
values: new object[,]
{
{ "Darker WinKer", null, "Be invisible in the darkness but never alone", "default", null, 9.99f },
{ "Summer Daffodil", null, "A jewel of Summer for all year long", "default", null, 9.99f }
});
migrationBuilder.CreateIndex(
name: "IX_Champion_ImageBase64",
table: "Champion",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_ChampionEntityRunePageEntity_RunePagesName",
table: "ChampionEntityRunePageEntity",
column: "RunePagesName");
migrationBuilder.CreateIndex(
name: "IX_ChampionEntitySkillEntity_SkillsName",
table: "ChampionEntitySkillEntity",
column: "SkillsName");
migrationBuilder.CreateIndex(
name: "IX_Characteristic_ChampionName",
table: "Characteristic",
column: "ChampionName");
migrationBuilder.CreateIndex(
name: "IX_Rune_ImageBase64",
table: "Rune",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_RuneEntityRunePageEntity_RunesName",
table: "RuneEntityRunePageEntity",
column: "RunesName");
migrationBuilder.CreateIndex(
name: "IX_Skin_ChampionSkinName",
table: "Skin",
column: "ChampionSkinName");
migrationBuilder.CreateIndex(
name: "IX_Skin_ImageBase64",
table: "Skin",
column: "ImageBase64");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChampionEntityRunePageEntity");
migrationBuilder.DropTable(
name: "ChampionEntitySkillEntity");
migrationBuilder.DropTable(
name: "Characteristic");
migrationBuilder.DropTable(
name: "RuneEntityRunePageEntity");
migrationBuilder.DropTable(
name: "Skin");
migrationBuilder.DropTable(
name: "Skill");
migrationBuilder.DropTable(
name: "RunePage");
migrationBuilder.DropTable(
name: "Rune");
migrationBuilder.DropTable(
name: "Champion");
migrationBuilder.DropTable(
name: "Image");
}
}
}

@ -0,0 +1,371 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.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("ChampionEntityRunePageEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "RunePagesName");
b.HasIndex("RunePagesName");
b.ToTable("ChampionEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
b.HasData(
new
{
Name = "WinKer",
Bio = "Best front-end designer",
Class = 3,
Icon = ""
},
new
{
Name = "Jonquille",
Bio = "Daffodil",
Class = 5,
Icon = ""
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionName")
.HasColumnType("TEXT");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionName");
b.ToTable("Characteristic");
b.HasData(
new
{
Name = "Front-end",
Value = 100
},
new
{
Name = "Back-end",
Value = 100
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
b.HasData(
new
{
Base64 = "default"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Rune");
b.HasData(
new
{
Name = "Mastering of Blue",
Description = "Blue shades",
Family = 2
},
new
{
Name = "Empty Shards",
Description = "Remove runes",
Family = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
b.HasData(
new
{
Name = "FirstRunepage"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
b.HasData(
new
{
Name = "Beautiful layout",
Description = "Bowl'In",
Type = 3
},
new
{
Name = "DB Support",
Description = "DB",
Type = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
b.HasData(
new
{
Name = "Darker WinKer",
Description = "Be invisible in the darkness but never alone",
Icon = "default",
Price = 9.99f
},
new
{
Name = "Summer Daffodil",
Description = "A jewel of Summer for all year long",
Icon = "default",
Price = 9.99f
});
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.Property<string>("RunesName")
.HasColumnType("TEXT");
b.HasKey("RunePagesName", "RunesName");
b.HasIndex("RunesName");
b.ToTable("RuneEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion")
.WithMany()
.HasForeignKey("ChampionName");
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null)
.WithMany()
.HasForeignKey("RunesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

@ -23,7 +23,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkLOL", "Entit
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{D24FBC48-F9C3-45CA-8D51-A851559C307F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{D24FBC48-F9C3-45CA-8D51-A851559C307F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagersEF", "ManagersEF\ManagersEF.csproj", "{A8685E74-67E4-4382-AF91-38045AC0014B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagersEF", "ManagersEF\ManagersEF.csproj", "{A8685E74-67E4-4382-AF91-38045AC0014B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestEF", "TestEF\TestEF.csproj", "{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -67,6 +69,10 @@ Global
{A8685E74-67E4-4382-AF91-38045AC0014B}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8685E74-67E4-4382-AF91-38045AC0014B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.Build.0 = Release|Any CPU {A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.Build.0 = Release|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -2,6 +2,8 @@
using Shared; using Shared;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using APILOL.Mapper; using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using System.Xml.Linq;
namespace ManagersEF namespace ManagersEF
{ {
@ -16,18 +18,26 @@ namespace ManagersEF
public async Task<Champion?> AddItem(Champion? item) public async Task<Champion?> AddItem(Champion? item)
{ {
await parent.DbContext.Champion.AddAsync(item.ToEntity()); await parent.DbContext.Champion.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item; return item;
} }
public async Task<bool> DeleteItem(Champion? item) public async Task<bool> DeleteItem(Champion? item)
{ {
parent.DbContext.Champion.Remove(item.ToEntity()); var toDelete = parent.DbContext.Champion.Find(item.Name);
return true; if (toDelete != null)
{
parent.DbContext.Champion.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
} }
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
Console.WriteLine("GET");
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering( return parent.DbContext.Champion.GetItemsWithFilterAndOrdering(
c => true, c => true,
index, count, index, count,
@ -37,7 +47,7 @@ namespace ManagersEF
public async Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering( return parent.DbContext.Champion.Include("Characteristics").GetItemsWithFilterAndOrdering(
c => c.Characteristics.Any(ch => ch.Name.Equals(charName)), c => c.Characteristics.Any(ch => ch.Name.Equals(charName)),
index, count, index, count,
orderingPropertyName, descending).Select(c => c.ToModel()); orderingPropertyName, descending).Select(c => c.ToModel());
@ -62,8 +72,8 @@ namespace ManagersEF
public async Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering( return parent.DbContext.Champion.Include("runepages").GetItemsWithFilterAndOrdering(
c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity())), c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity(parent.DbContext))),
index, count, index, count,
orderingPropertyName, descending).Select(c => c.ToModel()); orderingPropertyName, descending).Select(c => c.ToModel());
@ -79,7 +89,7 @@ namespace ManagersEF
public async Task<IEnumerable<Champion?>> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Champion?>> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering( return parent.DbContext.Champion.Include("Skills").GetItemsWithFilterAndOrdering(
c => skill != null && c.Skills.Any(s => s.Name.Equals(skill)), c => skill != null && c.Skills.Any(s => s.Name.Equals(skill)),
index, count, index, count,
orderingPropertyName, descending).Select(c => c.ToModel()); orderingPropertyName, descending).Select(c => c.ToModel());
@ -109,7 +119,7 @@ namespace ManagersEF
public async Task<int> GetNbItemsByRunePage(RunePage? runePage) public async Task<int> GetNbItemsByRunePage(RunePage? runePage)
{ {
return parent.DbContext.Champion.Where(c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity()))).Count(); return parent.DbContext.Champion.Where(c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity(parent.DbContext)))).Count();
} }
@ -127,8 +137,9 @@ namespace ManagersEF
public async Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem) public async Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
{ {
parent.DbContext.Champion.Remove(oldItem.ToEntity()); var toUpdate = parent.DbContext.Champion.Find(oldItem.Name);
parent.DbContext.Champion.Add(newItem.ToEntity()); toUpdate = newItem.ToEntity(parent.DbContext);
parent.DbContext.SaveChanges();
return newItem; return newItem;
} }
} }

@ -1,8 +1,11 @@
using APILOL.Mapper; using APILOL.Mapper;
using EntityFrameworkLOL.Entities;
using ManagersEF; using ManagersEF;
using Microsoft.EntityFrameworkCore;
using Model; using Model;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using System.Linq; using System.Linq;
using System.Xml.Linq;
namespace ManagersEF namespace ManagersEF
{ {
@ -17,14 +20,21 @@ namespace ManagersEF
public async Task<RunePage?> AddItem(RunePage? item) public async Task<RunePage?> AddItem(RunePage? item)
{ {
await parent.DbContext.RunePage.AddAsync(item.ToEntity()); await parent.DbContext.RunePage.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item; return item;
} }
public async Task<bool> DeleteItem(RunePage? item) public async Task<bool> DeleteItem(RunePage? item)
{ {
parent.DbContext.RunePage.Remove(item.ToEntity()); var toDelete = parent.DbContext.RunePage.Find(item.Name);
return true; if (toDelete != null)
{
parent.DbContext.RunePage.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
} }
public async Task<IEnumerable<RunePage?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<RunePage?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
@ -32,15 +42,15 @@ namespace ManagersEF
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering( return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering(
rp => true, rp => true,
index, count, index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel()); orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
} }
public async Task<IEnumerable<RunePage?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<RunePage?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering( return parent.DbContext.RunePage.Include("champions").GetItemsWithFilterAndOrdering(
rp => rp.Champions.Any(c => c.Name.Equals(champion.Name)), rp => rp.Champions.Any(c => c.Name.Equals(champion.Name)),
index, count, index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel()); orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
} }
public async Task<IEnumerable<RunePage?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<RunePage?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
@ -48,15 +58,15 @@ namespace ManagersEF
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering( return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering(
rp => rp.Name.Contains(substring), rp => rp.Name.Contains(substring),
index, count, index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel()); orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
} }
public async Task<IEnumerable<RunePage?>> GetItemsByRune(Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<RunePage?>> GetItemsByRune(Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering( return parent.DbContext.RunePage.Include("entries").GetItemsWithFilterAndOrdering(
rp => rp.Runes.Any(r => r.Name.Equals(rune.Name)), rp => rp.entries.Any(r => r.RuneName.Equals(rune.Name)),
index, count, index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel()); orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
} }
public async Task<int> GetNbItems() public async Task<int> GetNbItems()
@ -67,7 +77,7 @@ namespace ManagersEF
public async Task<int> GetNbItemsByChampion(Champion? champion) public async Task<int> GetNbItemsByChampion(Champion? champion)
{ {
return parent.DbContext.RunePage.Where(rp => rp.Champions.Any(c => c.Name.Equals(champion.Name))).Count(); return parent.DbContext.RunePage.Where(rp => rp.champions.Any(c => c.Name.Equals(champion.Name))).Count();
} }
@ -78,14 +88,27 @@ namespace ManagersEF
public async Task<int> GetNbItemsByRune(Model.Rune? rune) public async Task<int> GetNbItemsByRune(Model.Rune? rune)
{ {
return parent.DbContext.RunePage.Where(rp => rp.Runes.Any(r => r.Name.Equals(rune.Name))).Count(); return parent.DbContext.RunePage.Where(rp => rp.entries.Any(r => r.RuneName.Equals(rune.Name))).Count();
} }
public async Task<RunePage?> UpdateItem(RunePage? oldItem, RunePage? newItem) public async Task<RunePage?> UpdateItem(RunePage? oldItem, RunePage? newItem)
{ {
parent.DbContext.RunePage.Remove(oldItem.ToEntity()); var toUpdate = parent.DbContext.RunePage.Include("entries")
parent.DbContext.RunePage.Add(newItem.ToEntity()); .Where(x => x.Name.Equals(newItem.Name)).First();
try
{
toUpdate.entries = newItem.Runes.Select(r => new RunePageRuneEntity()
{
category = r.Key,
rune = r.Value.ToEntity(parent.DbContext),
}).ToList();
parent.DbContext.SaveChanges();
}
catch (DbUpdateException) { }
return newItem; return newItem;
} }
} }
} }

@ -1,6 +1,8 @@
using APILOL.Mapper; using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using Model; using Model;
using Shared; using Shared;
using System.Xml.Linq;
namespace ManagersEF namespace ManagersEF
{ {
@ -14,14 +16,21 @@ namespace ManagersEF
=> this.parent = parent; => this.parent = parent;
public async Task<Rune?> AddItem(Rune? item) public async Task<Rune?> AddItem(Rune? item)
{ {
await parent.DbContext.Rune.AddAsync(item.ToEntity()); await parent.DbContext.Rune.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item; return item;
} }
public async Task<bool> DeleteItem(Rune? item) public async Task<bool> DeleteItem(Rune? item)
{ {
parent.DbContext.Rune.Remove(item.ToEntity()); var toDelete = parent.DbContext.Rune.Find(item?.Name);
return true; if (toDelete != null)
{
parent.DbContext.Rune.Remove(item?.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return true;
}
return false;
} }
public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
@ -65,8 +74,10 @@ namespace ManagersEF
public async Task<Rune?> UpdateItem(Rune? oldItem, Rune? newItem) public async Task<Rune?> UpdateItem(Rune? oldItem, Rune? newItem)
{ {
parent.DbContext.Rune.Remove(oldItem.ToEntity()); var toUpdate = parent.DbContext.Rune.Find(oldItem.Name);
parent.DbContext.Rune.Add(newItem.ToEntity()); toUpdate.Description = newItem.Description;
toUpdate.Family = newItem.Family;
parent.DbContext.SaveChanges();
return newItem; return newItem;
} }
} }

@ -1,6 +1,8 @@
using APILOL.Mapper; using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using Model; using Model;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using System.Xml.Linq;
namespace ManagersEF namespace ManagersEF
{ {
@ -15,38 +17,45 @@ namespace ManagersEF
public async Task<Skin?> AddItem(Skin? item) public async Task<Skin?> AddItem(Skin? item)
{ {
await parent.DbContext.Skin.AddAsync(item.ToEntity()); await parent.DbContext.Skin.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item; return item;
} }
public async Task<bool> DeleteItem(Skin? item) public async Task<bool> DeleteItem(Skin? item)
{ {
parent.DbContext.Skin.Remove(item.ToEntity()); var toDelete = parent.DbContext.Skin.Find(item.Name);
return true; if (toDelete != null)
{
parent.DbContext.Skin.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
} }
public async Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering( return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => true, s => true,
index, count, index, count,
orderingPropertyName, descending).Select(s => s.ToModel()); orderingPropertyName, descending).Select(s => s?.ToModel());
} }
public async Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering( return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => s.Champion.Name.Equals(champion.Name), s => s.ChampionSkin.Name.Equals(champion?.Name),
index, count, index, count,
orderingPropertyName, descending).Select(s => s.ToModel()); orderingPropertyName, descending).Select(s => s?.ToModel());
} }
public async Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering( return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => s.Name.Contains(substring), s => s.Name.Contains(substring),
index, count, index, count,
orderingPropertyName, descending).Select(s => s.ToModel()); orderingPropertyName, descending).Select(s => s?.ToModel());
} }
public async Task<int> GetNbItems() public async Task<int> GetNbItems()
@ -56,8 +65,12 @@ namespace ManagersEF
public async Task<int> GetNbItemsByChampion(Champion? champion) public async Task<int> GetNbItemsByChampion(Champion? champion)
{ {
return parent.DbContext.Skin.Where(s => s.Champion.Name.Equals(champion.Name)) if (champion != null)
.Count(); {
return parent.DbContext.Skin.Where(s => s.ChampionSkin.Name.Equals(champion.Name))
.Count();
}
return 0;
} }
public async Task<int> GetNbItemsByName(string substring) public async Task<int> GetNbItemsByName(string substring)
@ -68,8 +81,8 @@ namespace ManagersEF
public async Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem) public async Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
{ {
parent.DbContext.Skin.Remove(oldItem.ToEntity()); var toUpdate = parent.DbContext.Skin.Find(oldItem.Name);
parent.DbContext.Skin.Add(newItem.ToEntity()); toUpdate.ChampionSkin = parent.DbContext.Champion.Find(newItem.Champion.Name);
return newItem; return newItem;
} }
} }

@ -6,6 +6,11 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" /> <ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" />

@ -20,6 +20,8 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" /> <ProjectReference Include="..\Shared\Shared.csproj" />

@ -14,6 +14,8 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -14,6 +14,8 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,189 @@
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System.Xml.Linq;
using Xunit.Abstractions;
using Xunit;
using ManagersEF;
namespace TestEF
{
public class TestChampions
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
batman.AddSkill(new("Bat-signal", SkillType.Basic, "Envoie le signal"));
batman.AddCharacteristics(new[] {
Tuple.Create("Force", 150),
Tuple.Create("Agilité", 500)
});
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
endeavor.AddSkill(new("Final flames", SkillType.Ultimate, "Dernière flamme d'un héro"));
endeavor.AddCharacteristics(new[] {
Tuple.Create("Force", 200),
Tuple.Create("Défense", 300),
Tuple.Create("Alter", 800)
});
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
escanor.AddSkill(new("Croissance solaire", SkillType.Passive, "Le soleil rends plus fort !"));
escanor.AddCharacteristics(new[] {
Tuple.Create("Force", 500),
Tuple.Create("Défense", 500)
});
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Batman", 0, nbItems);
Assert.Equal("Batman", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByName("E"));
items = await manager.GetItemsBySkill("Croissance solaire", 0, nbItems);
Assert.Equal("Escanor", items.First().Name);
items = await manager.GetItemsBySkill(new Skill("Final flames", SkillType.Ultimate, "Dernière flamme d'un héro"),
0, nbItems);
Assert.Equal("Endeavor", items.First().Name);
items = await manager.GetItemsByCharacteristic("Alter", 0, nbItems);
Assert.Equal("Endeavor", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByCharacteristic("Défense"));
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var items = await manager.GetItemsByName("E", 0, 3);
Assert.Equal(2, items.Count());
var escanor = context.Champion.Where(n => n.Name.Contains("Esc")).First();
escanor.Class = ChampionClass.Tank;
context.SaveChanges();
items = await manager.GetItemsByClass(ChampionClass.Tank, 0, 3);
Assert.Contains("Escanor", items.Select(x => x.Name));
Assert.Equal(2, await manager.GetNbItemsByClass(ChampionClass.Tank));
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
batman.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
batman.AddSkill(new("Double Saut", SkillType.Basic, ""));
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
endeavor.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
escanor.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
batman.AddSkill(new("Double Saut", SkillType.Basic, ""));
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var endeavor = (await manager.GetItemsByName("Endeavor", 0, 3)).First();
var itemsByName = await manager.DeleteItem(endeavor);
Assert.Equal(2, await manager.GetNbItems());
var items = await manager.GetItems(0, await manager.GetNbItems());
Assert.DoesNotContain("Endeavor", items.Select(x => x.Name));
Assert.Equal(1, await manager.GetNbItemsBySkill(new Skill("Double Saut", SkillType.Basic, "")));
Assert.Equal(2, await manager.GetNbItemsBySkill("Charge"));
}
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" />
<ProjectReference Include="..\APILOL\APILOL.csproj" />
<ProjectReference Include="..\ManagersEF\ManagersEF.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,277 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Model.RunePage;
using System.Xml.Linq;
using Xunit;
using EntityFrameworkLOL.DBContexts;
namespace TestEF
{
public class TestRunePages
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
await championManager.AddItem(escanor);
var runepage_entities = context.RunePage;
var champion_entities = context.Champion;
var damages = runepage_entities.Find("Damages");
var hawk = runepage_entities.Find("Hawk");
var juggler = runepage_entities.Find("Juggler");
champion_entities.Find("Batman")!.RunePages = new List<RunePageEntity>() { hawk, juggler };
champion_entities.Find("Endeavor")!.RunePages = new List<RunePageEntity>() { damages };
champion_entities.Find("Escanor")!.RunePages = new List<RunePageEntity>() { damages };
context.SaveChanges();
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Ha", 0, nbItems);
Assert.Equal("Hawk", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByName("a"));
Assert.Equal(1, await manager.GetNbItemsByRune(rune5));
items = await manager.GetItemsByRune(rune1, 0, nbItems);
Assert.Equal("Damages", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByChampion(batman));
Assert.Equal("Damages", (await manager.GetItemsByChampion(endeavor, 0, 3)).First()!.Name);
Assert.Equal(2, await championManager.GetNbItemsByRunePage(new("Damages")));
Assert.Equal("Batman", (await championManager.GetItemsByRunePage(new("Juggler"), 0, 3)).First()!.Name);
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
context.Database.EnsureCreated();
Assert.Equal(1, await manager.GetNbItemsByRune(rune1));
Assert.Equal(1, await manager.GetNbItemsByRune(rune6));
RunePage after = new("Hawk");
after[Category.Major] = rune1;
await manager.UpdateItem(new("Hawk"), after);
Assert.Equal(2, await manager.GetNbItemsByRune(rune1));
Assert.Equal(0, await manager.GetNbItemsByRune(rune6));
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
context.Database.EnsureCreated();
Assert.Equal(3, await manager.GetNbItems());
await manager.DeleteItem(new("Juggler"));
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(1, await manager.GetNbItemsByName("e"));
Assert.Equal(1, await manager.GetNbItemsByRune(rune2));
}
}
}
}

@ -0,0 +1,154 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace TestEF
{
public class TestRunes
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Sanglante", 0, nbItems);
Assert.Equal("Sanglante", items.First().Name);
Assert.Equal(1, await manager.GetNbItemsByName("Concrétisation"));
items = await manager.GetItemsByFamily(RuneFamily.Precision, 0, nbItems);
Assert.Equal("Oeil de l'esprit", items.First().Name);
Assert.Equal(1, await manager.GetNbItemsByFamily(RuneFamily.Unknown));
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Assert.Equal(1, await manager.GetNbItemsByFamily(RuneFamily.Precision));
Model.Rune before = new("Concrétisation", RuneFamily.Unknown);
Model.Rune after = new("Concrétisation", RuneFamily.Precision);
await manager.UpdateItem(before, after);
Assert.Equal(2, await manager.GetNbItemsByFamily(RuneFamily.Precision));
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Assert.Equal(3, await manager.GetNbItems());
await manager.DeleteItem(new("Concrétisation", RuneFamily.Unknown));
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(0, await manager.GetNbItemsByName("Concrétisation"));
}
}
}
}

@ -0,0 +1,182 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace TestEF
{
public class TestSkins
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(4, nbItems);
Assert.Equal(4, (await manager.GetItems(0, nbItems)).Count());
var items = await manager.GetItemsByName("Batman", 0, nbItems);
Assert.Equal(2, items.Count());
Champion batman = new("Batman", ChampionClass.Assassin);
items = await manager.GetItemsByChampion(batman, 0, nbItems);
Assert.Equal(3, items.Count());
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
var itemsByName = await manager.GetItemsByChampion(batman, 0, 4);
Assert.Equal(3, itemsByName.Count());
Skin batman_skin = new("L'homme araignée", batman);
Skin endeavor_skin = new("L'homme araignée", endeavor);
await manager.UpdateItem(batman_skin, endeavor_skin);
itemsByName = await manager.GetItemsByChampion(batman, 0, 4);
Assert.Equal(2, itemsByName.Count());
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
await manager.DeleteItem((await manager.GetItemsByName("L'", 0, 4)).First());
await manager.DeleteItem((await manager.GetItemsByName("L'", 0, 3)).First());
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(2, await manager.GetNbItemsByName("Batman"));
Champion batman = new("Batman", ChampionClass.Assassin);
Assert.Equal(2, await manager.GetNbItemsByChampion(batman));
}
}
}
}

@ -14,6 +14,8 @@
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" /> <PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> <PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" /> <PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -23,5 +23,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace TestsEF.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59431",
"sslPort": 44385
}
},
"profiles": {
"TestsEF": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7027;http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
namespace TestsEF
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading…
Cancel
Save