public async Task Entity_ListAsyncBySesshinId_Test() { // In-memory database only exists while the connection is open _connection.Open(); try { var options = CreateOptionAndEnsureCreated(); // Add an identity to the in memory database await AddEntities(new List <ModelBase> { _testModel, _testModel2 }, options); // Run the test against one instance of the context using (var context = new ProductContext(options)) { var repository = new EFDayOfSesshinRepository(context); IEnumerable <DayOfSesshin> days = await repository.ListAsyncBySesshinId(1); Assert.Equal(1, ((ICollection <DayOfSesshin>)days).Count); } } finally { _connection.Close(); } }
public async Task Entity_UpdateNumberOfPeopleAsync_Test() { // In-memory database only exists while the connection is open _connection.Open(); try { var options = CreateOptionAndEnsureCreated(); // Add an identity to the in memory database await AddEntities(new List <ModelBase> { _testModel }, options); // Run the test against one instance of the context using (var context = new ProductContext(options)) { var repository = new EFDayOfSesshinRepository(context); DayOfSesshin day = await context.DaysOfSesshin.SingleAsync(); await repository.UpdateNumberOfPeopleAsync(1, 70); await context.SaveChangesAsync(); } //Assert using (var context = new ProductContext(options)) { DayOfSesshin day = await context.DaysOfSesshin.SingleAsync(); Assert.Equal(70, day.NumberOfPeople); } } finally { _connection.Close(); } }