|
|
|
@ -28,7 +28,7 @@ namespace TestEF
|
|
|
|
|
Assert.Equal("Akali", champs.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Modify_Test()
|
|
|
|
|
{
|
|
|
|
@ -36,51 +36,49 @@ namespace TestEF
|
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
|
connection.Open();
|
|
|
|
|
|
|
|
|
|
var options = new DbContextOptionsBuilder<NounoursContext>()
|
|
|
|
|
.UseSqlite(connection)
|
|
|
|
|
.Options;
|
|
|
|
|
var options = new DbContextOptionsBuilder<SQLiteContext>().UseSqlite(connection).Options;
|
|
|
|
|
|
|
|
|
|
//prepares the database with one instance of the context
|
|
|
|
|
using (var context = new NounoursContext(options))
|
|
|
|
|
using (var context = new StubEFChampions(options))
|
|
|
|
|
{
|
|
|
|
|
//context.Database.OpenConnection();
|
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Nounours chewie = new Nounours { Nom = "Chewbacca" };
|
|
|
|
|
Nounours yoda = new Nounours { Nom = "Yoda" };
|
|
|
|
|
Nounours ewok = new Nounours { Nom = "Ewok" };
|
|
|
|
|
|
|
|
|
|
context.Nounours.Add(chewie);
|
|
|
|
|
context.Nounours.Add(yoda);
|
|
|
|
|
context.Nounours.Add(ewok);
|
|
|
|
|
context.Nounours.Add(ewok);*/
|
|
|
|
|
context.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
|
using (var context = new NounoursContext(options))
|
|
|
|
|
using (var context = new StubEFChampions(options))
|
|
|
|
|
{
|
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
|
|
|
|
|
|
string nameToFind = "ew";
|
|
|
|
|
Assert.Equal(2, context.Nounours.Where(n => n.Nom.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
nameToFind = "wo";
|
|
|
|
|
Assert.Equal(1, context.Nounours.Where(n => n.Nom.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
var ewok = context.Nounours.Where(n => n.Nom.ToLower().Contains(nameToFind)).First();
|
|
|
|
|
ewok.Nom = "Wicket";
|
|
|
|
|
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
var ewok = context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).First();
|
|
|
|
|
ewok.Name = "Wicket";
|
|
|
|
|
context.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
|
using (var context = new NounoursContext(options))
|
|
|
|
|
using (var context = new StubEFChampions(options))
|
|
|
|
|
{
|
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
|
|
|
|
|
|
string nameToFind = "ew";
|
|
|
|
|
Assert.Equal(1, context.Nounours.Where(n => n.Nom.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
nameToFind = "wick";
|
|
|
|
|
Assert.Equal(1, context.Nounours.Where(n => n.Nom.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
/*
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
@ -126,8 +124,8 @@ namespace TestEF
|
|
|
|
|
var champions = objectResult?.Value as ChampionDto;
|
|
|
|
|
Assert.IsNotNull(champions);
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|