public async void CanDeleteRecordingCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("LingUpdateDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { Recording rec = new Recording(); rec.Transcription = "English"; rec.ID = 1; context.Recordings.Add(rec); context.SaveChanges(); var newRecording = await context.Recordings.FirstOrDefaultAsync(x => x.Transcription == rec.Transcription); context.Recordings.Remove(newRecording); context.SaveChanges(); var deletedRecording = await context.Recordings.FirstOrDefaultAsync(l => l.Transcription == newRecording.Transcription); Assert.True(deletedRecording == null); } }
public async void CanUpdateLangCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("LingUpdateDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { Language lang = new Language(); lang.EnglishName = "English"; lang.ISOCode = "en-US"; context.Languages.Add(lang); context.SaveChanges(); lang.EnglishName = "Spanish"; context.Languages.Update(lang); context.SaveChanges(); var myLang = await context.Languages.FirstOrDefaultAsync(x => x.EnglishName == lang.EnglishName); Assert.Equal("Spanish", myLang.EnglishName); } }
public async void CanDeleteLangCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("LingUpdateDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { Language lang = new Language(); lang.EnglishName = "English"; lang.ISOCode = "en-US"; context.Languages.Add(lang); context.SaveChanges(); var newLang = await context.Languages.FirstOrDefaultAsync(x => x.EnglishName == lang.EnglishName); context.Languages.Remove(newLang); context.SaveChanges(); var deletedLang = await context.Languages.FirstOrDefaultAsync(l => l.EnglishName == newLang.EnglishName); Assert.True(deletedLang == null); } }
public async void CanUpdateRecordingCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("RecordingUpdateDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { Recording rec = new Recording(); rec.Transcription = "English"; rec.ID = 1; context.Recordings.Add(rec); context.SaveChanges(); rec.Transcription = "Spanish"; context.Recordings.Update(rec); context.SaveChanges(); var newRecording = await context.Recordings.FirstOrDefaultAsync(l => l.Transcription == rec.Transcription); Assert.Equal("Spanish", newRecording.Transcription); } }
public async void CanCreateLangCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("LingCreateDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { // Create Language lang = new Language(); lang.EnglishName = "Dutch"; lang.ISOCode = "uk-EUR"; context.Languages.Add(lang); context.SaveChanges(); var createdLang = await context.Languages.FirstOrDefaultAsync(x => x.EnglishName == lang.EnglishName); Assert.Equal("Dutch", createdLang.EnglishName); } }
public async void CanReadRecordingCRUDTest() { DbContextOptions <LingDbContext> options = new DbContextOptionsBuilder <LingDbContext>() .UseInMemoryDatabase("RecordingReadDBContex") .Options; using (LingDbContext context = new LingDbContext(options)) { // Read Recording rec = new Recording(); rec.Transcription = "English"; rec.ID = 1; context.Recordings.Add(rec); context.SaveChanges(); var myRec = await context.Recordings.FirstOrDefaultAsync(x => x.Transcription == rec.Transcription); Assert.Equal(1, myRec.ID); } }