public void TestAddAndCountMovies() { _toTest.Add(new Movie( "My movie", @"D:\repo\Something.stuff", "2019-12-31")); int expected = 1; int actual = _toTest.SearchMovies("My movie").Length; Assert.AreEqual(expected, actual); }
public static void ClassSetup(TestContext testContext) { // In-memory database only exists while the connection is open _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); // Custom options passed to DbContext var options = new DbContextOptionsBuilder <MediaLibraryDbContext>() .UseSqlite(_connection) .Options; // Instantiate the custom context var context = new MediaLibraryDbContext(options); // Instantiate the class to test var service = new MediaLibraryService(context); // Create the schema in the database context.Database.EnsureCreated(); // Add a movie service.Add( new Movie( "My movie", @"D:\repo\Something.stuff", "2019-12-31") ); // Add another movie service.Add( new Movie( "My movie 2", @"D:\repo\Something2.stuff", "2020-12-31") ); }