parent
ab1e33a816
commit
459400406c
@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Model2\LibEntityFramework.csproj" />
|
||||
<ProjectReference Include="..\TrucAuMilieu\TrucAuMilieu.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,43 @@
|
||||
using LibEntityFramework;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Model;
|
||||
using TrucAuMilieu;
|
||||
|
||||
namespace TestsTresImportants
|
||||
{
|
||||
public class UTestsChampion
|
||||
{
|
||||
[Fact]
|
||||
public void Test()
|
||||
{
|
||||
var connection = new SqliteConnection("DataSource=:memory:");
|
||||
connection.Open();
|
||||
|
||||
var options = new DbContextOptionsBuilder<ChampionContext>()
|
||||
.UseSqlite(connection)
|
||||
.Options;
|
||||
|
||||
using (var context = new ChampionContext(options))
|
||||
{
|
||||
context.Database.EnsureCreated();
|
||||
|
||||
Champion c1 = new Champion("Joe");
|
||||
Champion c2 = new Champion("Billy");
|
||||
Champion c3 = new Champion("Robert");
|
||||
|
||||
context.Champs.Add(c1.ChampToEf());
|
||||
context.Champs.Add(c2.ChampToEf());
|
||||
context.Champs.Add(c3.ChampToEf());
|
||||
context.SaveChanges();
|
||||
}
|
||||
using(var context= new ChampionContext(options))
|
||||
{
|
||||
context.Database.EnsureCreated();
|
||||
Assert.Equal(3, context.Champs.Count());
|
||||
Assert.Equal("Joe", context.Champs.First().Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
global using Xunit;
|
Loading…
Reference in new issue