public void GetAllTags_returns_empty_if_thereAreNoTags() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <PlanificatorDbContext>() .UseSqlite(connection) .Options; using (var context = new PlanificatorDbContext(options)) { context.Database.EnsureCreated(); var service = new PresentationRepository(context); Assert.Empty(service.GetAllTagsNames(0)); Assert.Empty(service.GetAllTagsNames(1)); Assert.Empty(service.GetAllTagsNames(2)); Assert.Empty(service.GetAllTagsNames(3)); } } finally { connection.Close(); } }
public async Task AddPresentation_writes_to_databaseAsync() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <PlanificatorDbContext>() .UseSqlite(connection) .Options; using (var context = new PlanificatorDbContext(options)) { context.Database.EnsureCreated(); var service = new PresentationManager(context); var query = new PresentationRepository(context); var testData = new PresentationRepositoryTestsData(); await service.AddPresentation(testData.presentationTags); context.SaveChanges(); List <string> tagsNames = testData.tags.Select(tag => tag.TagName).ToList(); Assert.Equal(tagsNames.Count, query.GetAllTagsNames(testData.presentation.PresentationId).Count()); Assert.Equal(tagsNames, query.GetAllTagsNames(testData.presentation.PresentationId)); } } finally { connection.Close(); } }