modifications des tests

master
Tom RAMBEAU 1 year ago
parent 0c51fa72bd
commit f040e94c6a

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -143,6 +143,7 @@ namespace UnitTests
}
}
[Fact]
public void Delete_TestPerson()
{
var connection = new SqliteConnection("DataSource=:memory:");
@ -165,25 +166,25 @@ namespace UnitTests
}
}
[Fact]
public void Delete_TestBook()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LibraryContext>().UseSqlite().Options;
var nb;
//prepares the database with one instance of the context
//prepares the database with one instance of the context
using (var context = new StubbedContext(options))
{
context.PersonSet.Include(pers => pers.Books).ToList();
nb = context.BooksSet.Count();
var nb = context.BooksSet.Count();
if (nb > 0)
{
context.BooksSet.Remove(context.BooksSet.FirstOrDefault());
}
Assert.Equal(context.BooksSet.Count, nb - 1);
Assert.Equal(context.BooksSet.Count(), nb - 1);
context.SaveChanges();
}
}

Loading…
Cancel
Save