public async Task GetAllLanguagesShouldReturnTheCorrectCount() { var options = new DbContextOptionsBuilder <AlexandriaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var db = new AlexandriaDbContext(options); var languages = new List <EditionLanguage>(); for (int i = 1; i <= 10; i++) { languages.Add( new EditionLanguage { Name = $"test{i}", }); } await db.EditionLanguages.AddRangeAsync(languages); await db.SaveChangesAsync(); var languagesService = new EditionLanguagesService(db); var result = await languagesService.GetAllLanguagesAsync <LanguageTestModel>(); Assert.Equal(10, result.Count()); }
public async Task DoesEditionLanguageExistShouldReturnFalseWhenNotFound() { var options = new DbContextOptionsBuilder <AlexandriaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var db = new AlexandriaDbContext(options); await db.EditionLanguages.AddRangeAsync( new EditionLanguage { Name = "test1", }, new EditionLanguage { Name = "test2", }, new EditionLanguage { Name = "test3", }); await db.SaveChangesAsync(); var languagesService = new EditionLanguagesService(db); Assert.False(await languagesService.DoesEditionLanguageIdExistAsync(5)); }