Update Test EF
continuous-integration/drone/push Build is failing Details

master
Louwar 2 years ago
parent d4f6fdad0e
commit 565c0860e2

@ -21,4 +21,8 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\API\API.csproj" />
</ItemGroup>
</Project> </Project>

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