feat : ajout du test du data manager d'une answer
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent f3a24c1f61
commit fb6eec6c67

@ -31,17 +31,8 @@ namespace ServiceManagers
public async Task<(int nbPages, IEnumerable<AnswerDto>? answers)> getAnswers(int nb, int count, AnswerOrderCriteria orderCriteria = AnswerOrderCriteria.ById) public async Task<(int nbPages, IEnumerable<AnswerDto>? answers)> getAnswers(int nb, int count, AnswerOrderCriteria orderCriteria = AnswerOrderCriteria.ById)
{ {
List<AnswerDto>? tmp = new List<AnswerDto>();
var res = await manager.getAnswers(nb, count, orderCriteria); var res = await manager.getAnswers(nb, count, orderCriteria);
if (res.answers == null) tmp = null; return (res.nbPages, res.answers?.Select(a => a.ToDto()));
else
{
foreach (var item in res.answers)
{
tmp.Add(item.ToDto());
}
}
return (res.nbPages, tmp);
} }
public async Task<IEnumerable<AnswerDto>?> getAnswersByIdQuestion(int id) public async Task<IEnumerable<AnswerDto>?> getAnswersByIdQuestion(int id)

@ -0,0 +1,641 @@
using DataManagers;
using DbConnectionLibrairie;
using DTOs;
using EntityManagers;
using ExtensionsClassLibrairie;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using OrderCriterias;
using ServiceManagers;
using StubbedDbContextLibrary;
// for each test, 'WF' mean 'waiting for'
/// <summary>
/// test of the 'addAnswer' method of an AnswerManager
/// </summary>
void TestAddAnswer()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var opt = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlite(connection)
.Options;
using (var context = new MyDbContext(opt))
{
context.Database.EnsureCreated();
var manager = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
var answerToAdd = new AnswerDto { Id = 1, Content = "chateîgne" };
var a = manager.addAnswer(answerToAdd).Result;
// 1) normal insertion
// WF : a is the same
// as answerToAdd
if (a.Content == answerToAdd.Content && a.Id == answerToAdd.Id && context.Answers.Single(e => e.Id == a.Id).Content == a.Content)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 1 AnswerServiceManager.addAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 1 AnswerServiceManager.addAnswer KO");
Console.ResetColor();
Console.WriteLine($"what we have : {a.Id} : {a.Content}");
Console.WriteLine($"WF : {answerToAdd.Id} : {answerToAdd.Content}");
}
answerToAdd = new AnswerDto { Id = 5, Content = "damien" };
a = manager.addAnswer(answerToAdd).Result;
// 2) with a random id greater than 0
// WF : 'a' content is equal to the
// content of 'answerToAdd'
// and since it's the second answer
// that we add, his id equal 2
if (a.Content == answerToAdd.Content && a.Id == 2 && context.Answers.Single(e => e.Id == 2).Content == a.Content)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 2 AnswerServiceManager.addAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 2 AnswerServiceManager.addAnswer KO");
Console.ResetColor();
Console.WriteLine($"what we have : {a.Id} : {a.Content}");
Console.WriteLine($"WF : 2 : {answerToAdd.Content}");
}
answerToAdd = new AnswerDto { Id = 7, Content = "chateîgne" };
a = manager.addAnswer(answerToAdd).Result;
// 3) with a content that we already have added
// WF : the function return the answer which already
// have the same content so the content of 'a' is "châteigne"
// and his id is 1
if (a.Content == "chateîgne" && a.Id == 1)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 3 AnswerServiceManager.addAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 3 AnswerServiceManager.addAnswer KO");
Console.ResetColor();
Console.WriteLine($"what we have : {a.Id} : {a.Content}");
Console.WriteLine($"WF : 1 : {answerToAdd.Content}");
}
answerToAdd = new AnswerDto { Id = 7, Content = "CHATEÎGNE" };
a = manager.addAnswer(answerToAdd).Result;
// 3) with a content that we already have added
// but in upperCase instead of lowerCase
// WF : the function return the answer which
// already have the same content so the content
// of 'a' is "chateîgne" and his id is 1
if (a.Content == "chateîgne" && a.Id == 1)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 4 AnswerServiceManager.addAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 4 AnswerServiceManager.addAnswer KO");
Console.ResetColor();
Console.WriteLine($"what we have : {a.Id} : {a.Content}");
Console.WriteLine($"WF : 1 : {answerToAdd.Content.ToLower()}");
}
foreach (var item in context.Answers) context.Answers.Remove(item); // we remove all database answers
context.SaveChanges();
}
}
/// <summary>
/// test of the 'supprimerAnswer' method of an AnswerManager
/// </summary>
void TestRemoveAnswerById(MyDbContext context)
{
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
var a = mgr.removeAnswer(context.Answers.Select(a => a.Id).Max() + 1).Result;
// 1) with an id greater or equal
// to the number of element
// WF : it don't works so 'a' is null,
if (a == null)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 1 AnswerServiceManager.removeAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 1 AnswerServiceManager.removeAnswer KO");
Console.ResetColor();
Console.WriteLine("what we have : " + a == null ? "null" : $"{a.Id} : {a.Content}");
Console.WriteLine("WF : null");
}
var answer = context.Answers.Single(a => a.Id == context.Answers.Select(a => a.Id).Min());
a = mgr.removeAnswer(context.Answers.Select(a => a.Id).Min()).Result;
// 1) with an id that is allowed to an answer
// WF : it works so 'a' is not null,
// and since we've delete the answer with
// the id 1, the content is "châteigne"
if (a != null && a.Content == answer.Content
&& a.Id == answer.Id && a.Id != context.Answers.Select(a => a.Id).Min() /* <=> he is removed */)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 2 AnswerServiceManager.removeAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 2 AnswerServiceManager.removeAnswer KO");
Console.ResetColor();
Console.WriteLine("what we have : " + a == null ? "null" : $"{a!.Id} : {a!.Content}");
Console.WriteLine("WF : " + answer == null ? "null" : $"{answer.Id} : {answer.Content}");
}
}
/// <summary>
/// test of the 'getNbElement' method of an AnswerManager
/// </summary>
void TestGetNbAnswers()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var opt = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlite(connection)
.Options;
using (var context = new MyDbContext(opt))
{
context.Database.EnsureCreated();
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
int count = context.Answers.CountAsync().Result;
int nb = 0;
var list = new List<AnswerDto>()
{
new AnswerDto { Content = "Ajout 1" },
new AnswerDto { Content = "Ajout 2" },
new AnswerDto { Content = "Ajout 3" },
new AnswerDto { Content = "Ajout 4" },
new AnswerDto { Content = "Ajout 5" },
new AnswerDto { Content = "Ajout 6" },
new AnswerDto { Content = "Ajout 7" },
new AnswerDto { Content = "Ajout 8" },
new AnswerDto { Content = "Ajout 9" },
new AnswerDto { Content = "Ajout 10" }
};
foreach (var answer in list)
{
var tmp = mgr.addAnswer(answer).Result;
count++;
nb++;
if (mgr.getNbAnswers() == count)
{ // ok, it's incremented
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {nb} AnswerServiceManager.getNbAnswers OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {nb} AnswerServiceManager.getNbAnswers KO");
Console.ResetColor();
Console.WriteLine($"what we have : {mgr.getNbAnswers()}");
Console.WriteLine($"WF : {count}");
}
}
}
}
/// <summary>
/// member data for the 'TestGetAnswer' test method
/// </summary>
/// <returns>a set of all inline datas for the test method</returns>
(int id, AnswerDto? waiting)[] TestGetAnswer_Datas(MyDbContext context)
{
var datas = context.Answers;
int max = 0;
(int id, AnswerDto? waiting)[] tmp = new (int id, AnswerDto? waiting)[] { };
foreach (var item in datas)
{
tmp.Append((item.Id, item.ToDto()));
if (max < item.Id) max = item.Id;
}
tmp.Append((max + 1, null!));
return tmp;
}
/// <summary>
/// test of the 'getAnswer' method of an AnswerManager
/// </summary>
/// <param name="id">identifiant of the answer to get</param>
/// <param name="waiting">answer expected</param>
/// <returns>nothing but a Task</returns>
void TestGetAnswer(MyDbContext context, int numTest, int id, AnswerDto? waiting)
{
context.Database.EnsureCreated();
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
var tmp = mgr.getAnswer(id).Result;
if (tmp?.Content == waiting?.Content)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {numTest} AnswerServiceManager.getAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {numTest} AnswerServiceManager.getAnswer KO");
Console.ResetColor();
}
}
/// <summary>
/// member data for the 'TestGetAnswer' test method
/// </summary>
/// <returns>a set of all inline datas for the test method</returns>
(int numPage, int count, IEnumerable<AnswerDto>? waiting, AnswerOrderCriteria? orderCriteria)[] TestGetSomeAnswers_Datas(MyDbContext context)
{
var tmp = context.Answers;
var datas = new List<AnswerDto>();
foreach (var item in tmp) datas.Add(item.ToDto());
var tmp2 = context.Answers.OrderBy(a => a.Content);
var datas2 = new List<AnswerDto>();
foreach (var item in tmp2) datas2.Add(item.ToDto());
var count = datas.Count();
// remind that to add answers, we haven't ordered this collection
// but we just have done a foreach
return [
// 1/2 : 0 answer from the page 1 then, -1 answer from this page
// WF : count < 1 so we got null
(1, 0, null, null),
(1, -1, null, null),
// 3/4 : 1 answers from the page 0 then, 1 answers from the page -1
// WF : page < 1 so we got null
(0, 1, null, null),
(-1, 1, null, null),
// 5 : 10 answers from the page 1
// WF : the first 10 element of datas
(1, 10, datas.Take(10), null),
// 6 : 10 elements from the page 1 order by id
// WF : the first 10 element of datas order by id
(1, 10, datas.OrderBy(e => e.Id).Take(10), AnswerOrderCriteria.ById),
// 7 : 10 elements from the page 1 order by content
// WF : the first 10 element of datas order by content
(1, 10, datas2.Take(10), AnswerOrderCriteria.ByContent),
// 8/9/10 : repeat 3, 4 and 5 with the page 2
// WF : the 10 next answer from each case
(2, 10, datas.Skip(10).Take(10), null),
(2, 10, datas.OrderBy(e => e.Id).Skip(10).Take(10), AnswerOrderCriteria.ById),
(2, 10, datas2.Skip(10).Take(10), AnswerOrderCriteria.ByContent),
// 11 : count/4 elements from the page 4
// WF : the lasts count/4 elements of datas
(4, count / 4, datas.Skip(3*count/4).Take(count/4), null),
// 12 : count/4 elements from the page 5
// WF : null since num (4) >= count / (count/4)
(3, count / 2, null, null),
// 13 : 7 elements from the page 5
// WF : since there's only 30 elements in fake datas,
// we got the 2 last elements
(5, 7, datas.Skip(28).Take(2), null)
];
}
/// <summary>
/// test of the 'getAnswer' method of an AnswerManager
/// </summary>
/// <param name="num">the page number</param>
/// <param name="count">page elements number</param>
/// <param name="waiting">set of answers expected</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>nothing but a Task</returns>
void TestGetSomeAnswers(MyDbContext context, int numTest, int num, int count, List<AnswerDto>? waiting, AnswerOrderCriteria? orderCriteria)
{
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
float nbPages = count == 0 ? -1 : (float)mgr.getNbAnswers() / count;
if (nbPages != (int)nbPages) nbPages++;
(int nbPages, IEnumerable<AnswerDto>? answers) tmp = orderCriteria == null ? mgr.getAnswers(num, count).Result : mgr.getAnswers(num, count, orderCriteria.Value).Result;
if (tmp.nbPages == (int)nbPages)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {2 * numTest} AnswerServiceManager.getSomeAnswers OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {2 * numTest} AnswerServiceManager.getSomeAnswers KO");
Console.ResetColor();
}
if (waiting == null && tmp.answers == null)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers OK");
Console.ResetColor();
}
else if (waiting != null && tmp.answers != null)
{
if (waiting.Count() == 0 && tmp.answers.Count() == 0)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers OK");
Console.ResetColor();
}
else if (waiting.Count() != 0 && tmp.answers.Count() != 0)
{
var nbFautes = 0;
for (var i = 0; i < waiting.Count(); i++)
{
var e1 = waiting!.ElementAt(i);
var e2 = tmp.answers!.ElementAt(i);
if (e2.Content != e1.Content || e2.IdQuestion != e1.IdQuestion) nbFautes++;
}
if (nbFautes == 0)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers KO");
Console.ResetColor();
Console.WriteLine($"numPage : {num}, count : {count}");
Console.Write("what we have : ");
if (tmp.answers == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
tmp.answers.ToList().ForEach(a => Console.Write("{" + $"{a.Id}" + "}, ")); // I know that I use sames collections
Console.WriteLine("}");
Console.WriteLine($"([{tmp.answers.Select(a => a.Id).Min()}, {tmp.answers.Select(a => a.Id).Max()}], {tmp.answers.Count()})");
}
Console.WriteLine();
Console.Write("WF : ");
if (waiting == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
waiting.ForEach(a => Console.Write("{" + $"{a.Id}" + "}, "));
Console.WriteLine("}");
Console.WriteLine($"([{waiting.Select(a => a.Id).Min()}, {waiting.Select(a => a.Id).Max()}], {waiting.Count()})");
}
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers KO");
Console.ResetColor();
Console.WriteLine($"numPage : {num}, count : {count}, nbEl : {mgr.getNbAnswers()}");
Console.Write("what we have : ");
if (tmp.answers == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
tmp.answers.ToList().ForEach(a => Console.Write("{" + $"{a.Id}" + "}, "));
Console.WriteLine("}");
Console.WriteLine($"([{tmp.answers.Select(a => a.Id).Min()}, {tmp.answers.Select(a => a.Id).Max()}], {tmp.answers.Count()})");
}
Console.WriteLine();
Console.Write("WF : ");
if (waiting == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
waiting.ForEach(a => Console.Write("{" + $"{a.Id}" + "}, "));
Console.WriteLine("}");
if(waiting.Count() != 0) Console.WriteLine($"([{waiting.Select(a => a.Id).Min()}, {waiting.Select(a => a.Id).Max()}], {waiting.Count()})");
}
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"test {2 * numTest + 1} AnswerServiceManager.getSomeAnswers KO");
Console.ResetColor();
Console.WriteLine($"numPage : {num}, count : {count}");
Console.Write("what we have : ");
if (tmp.answers == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
tmp.answers.ToList().ForEach(a => Console.Write("{" + $"{a.Id}" + "}, "));
Console.WriteLine("}");
Console.WriteLine($"([{tmp.answers.Select(a => a.Id).Min()}, {tmp.answers.Select(a => a.Id).Max()}], {tmp.answers.Count()})");
}
Console.WriteLine();
Console.Write("WF : ");
if (waiting == null) Console.WriteLine("null");
else
{
Console.Write("{ ");
waiting.ForEach(a => Console.Write("{" + $"{a.Id}" + "}, "));
Console.WriteLine("}");
Console.WriteLine($"([{waiting.Select(a => a.Id).Min()}, {waiting.Select(a => a.Id).Max()}], {waiting.Count()})");
}
}
}
/// <summary>
/// test of the 'supprimerAnswer' method of an AnswerManager
/// </summary>
void TestRemoveAnswer(MyDbContext context)
{
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
var a = mgr.removeAnswer(new AnswerDto { Content = "test remove answer" }).Result;
// 1) with an id greater or equal
// to the number of element
// WF : it don't works so 'a' is null,
if (a == null)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 1 AnswerServiceManager.removeAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 1 AnswerServiceManager.removeAnswer KO");
Console.ResetColor();
Console.WriteLine("what we have : " + a == null ? "null" : $"{a.Id} : {a.Content}");
Console.WriteLine("WF : null");
}
var answer = context.Answers.Single(a => a.Id == context.Answers.Select(a => a.Id).Min());
a = mgr.removeAnswer(answer.ToDto()).Result;
// 1) with a content that correspond to an answer
// WF : it works so 'a' is not null,
// and since we've delete the answer with
// the id 1, the content is "châteigne"
if (a != null && a.Content == answer.Content
&& a.Id == answer.Id && a.Id != context.Answers.Select(a => a.Id).Min() /* <=> he is removed */)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("test 2 AnswerServiceManager.removeAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 2 AnswerServiceManager.removeAnswer KO");
Console.ResetColor();
Console.WriteLine("what we have : " + a == null ? "null" : $"{a!.Id} : {a!.Content}");
Console.WriteLine("WF : " + answer == null ? "null" : $"{answer.Id} : {answer.Content}");
}
}
(int id, AnswerDto modified, AnswerDto? waiting)[] TestUpdateAnswer_Datas(MyDbContext context)
{
return new (int, AnswerDto, AnswerDto?)[]
{
// 1) with an id that is not allowed
// WF : since no answer match with this id,
// the function return null
(
context.Answers.Select(a => a.Id).Max() + 1,
new AnswerDto
{
Id = 3,
Content = "we don't care about"
},
null
),
// 2) with a content that correspond to the content of another answer
// WF : since some answers can each have same content, it work
// and the id of the answer we got is the one we give (content.Answers.Select.(a => a.id.Min())
// and his content is the one we want
(
context.Answers.Select(a => a.Id).Min(),
new AnswerDto
{
Id = 5,
Content = context.Answers.Single(a => a.Id == context.Answers.Select(a => a.Id).Min()).Content,
},
new AnswerDto
{
Id = context.Answers.Select(a => a.Id).Min(),
Content = context.Answers.Single(a => a.Id == context.Answers.Select(a => a.Id).Min()).Content,
}
),
// 3) normal insertion
// WF : the id of the answer we got is the one we
// give (content.Answers.Select.(a => a.id.Min())
// and his content is the one we want
(
context.Answers.Select(a => a.Id).Max(),
new AnswerDto
{
Id = context.Answers.Select(a => a.Id).Min(),
Content = context.Answers.First().Content
},
new AnswerDto
{
Id = context.Answers.Select(a => a.Id).Max(),
Content = context.Answers.First().Content
}
)
};
}
void TestUpdateAnswer(MyDbContext context, int numTest, int id, AnswerDto modified, AnswerDto? waiting)
{
var mgr = new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(context)));
var response = mgr.updateAnswer(id, modified).Result;
if ((waiting == null && response == null) || (waiting != null && response != null && response.Id == id && response.Content == waiting.Content))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"test {numTest} AnswerServiceManager.updateAnswer OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("test 2 AnswerServiceManager.removeAnswer KO");
Console.ResetColor();
Console.WriteLine("what we have : " + response == null ? "null" : $"{id} : {response!.Content}");
Console.WriteLine("WF : " + waiting == null ? "null" : $"{waiting!.Id} : {waiting.Content}");
}
}
// Tests of an answer
void TestAnswer(MyDbContext context)
{
TestAddAnswer();
TestRemoveAnswerById(context);
TestGetNbAnswers();
{
var tmp = TestGetAnswer_Datas(context);
for (int i = 0; i < tmp.Count(); i++)
{
TestGetAnswer(
context,
i + 1,
tmp.ElementAt(i).id,
tmp.ElementAt(i).waiting
);
}
}
{
var tmp = TestGetSomeAnswers_Datas(context);
for (int i = 0; i < tmp.Count(); i++)
{
TestGetSomeAnswers(
context,
i + 1,
tmp.ElementAt(i).numPage,
tmp.ElementAt(i).count,
tmp.ElementAt(i).waiting?.ToList(),
tmp.ElementAt(i).orderCriteria
);
}
}
TestRemoveAnswer(context);
{
var tmp = TestUpdateAnswer_Datas(context);
for (int i = 0; i < tmp.Count(); i++)
{
TestUpdateAnswer(
context,
i + 1,
tmp.ElementAt(i).id,
tmp.ElementAt(i).modified,
tmp.ElementAt(i).waiting
);
}
}
}
void Test(MyDbContext context)
{
TestAnswer(context);
}
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var opt = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlite(connection)
.Options;
using var context = new StubbedDbContext(opt);
context.Database.EnsureCreated();
Test(context);

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DbConnectionLibrairie\DbConnectionLibrairie.csproj" />
<ProjectReference Include="..\DTOs\DTOs.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" />
<ProjectReference Include="..\EntityManagers\EntityManagers.csproj" />
<ProjectReference Include="..\ExtensionsClassLibrairie\ExtensionsClassLibrairie.csproj" />
<ProjectReference Include="..\FakeDatas\FakeDatas.csproj" />
<ProjectReference Include="..\ManagerInterfaces\ManagerInterfaces.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\OrderCriterias\OrderCriterias.csproj" />
<ProjectReference Include="..\ServiceManagers\ServiceManagers.csproj" />
<ProjectReference Include="..\StubbedDbContextLibrary\StubbedDbContextLibrary.csproj" />
</ItemGroup>
</Project>

@ -31,7 +31,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeDatas", "FakeDatas\Fake
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedDbContextLibrary", "StubbedDbContextLibrary\StubbedDbContextLibrary.csproj", "{6A0D9093-EAA4-45A0-8813-ED5BB4E1EA3E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedDbContextLibrary", "StubbedDbContextLibrary\StubbedDbContextLibrary.csproj", "{6A0D9093-EAA4-45A0-8813-ED5BB4E1EA3E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestEntityManagers", "TestEntityManagers\TestEntityManagers.csproj", "{F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestEntityManagers", "TestEntityManagers\TestEntityManagers.csproj", "{F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServiceManagers", "TestServiceManagers\TestServiceManagers.csproj", "{0C04BD99-636A-48CA-ACFE-D2BF544E2C05}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestDataManagers", "TestDataManagers\TestDataManagers.csproj", "{F47BB104-98B0-473F-A75C-64A1A399ED56}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -99,6 +103,14 @@ Global
{F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Debug|Any CPU.Build.0 = Debug|Any CPU {F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Release|Any CPU.Build.0 = Release|Any CPU {F0758B69-FD20-4BC4-BE0F-5868DB8BF74E}.Release|Any CPU.Build.0 = Release|Any CPU
{0C04BD99-636A-48CA-ACFE-D2BF544E2C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C04BD99-636A-48CA-ACFE-D2BF544E2C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C04BD99-636A-48CA-ACFE-D2BF544E2C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C04BD99-636A-48CA-ACFE-D2BF544E2C05}.Release|Any CPU.Build.0 = Release|Any CPU
{F47BB104-98B0-473F-A75C-64A1A399ED56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F47BB104-98B0-473F-A75C-64A1A399ED56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F47BB104-98B0-473F-A75C-64A1A399ED56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F47BB104-98B0-473F-A75C-64A1A399ED56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save