public void InsertReadAlbumTest() { string name = MethodBase.GetCurrentMethod().Name; DaoGateway manager = new DaoGateway(connectionstring); const int FakeId = int.MinValue; Album album = new Album { Id = FakeId, Name = name, ReleaseYear = 1986 }; manager.InsertAlbum(album); Assert.AreNotEqual(FakeId, album.Id); List<Album> albums = manager.ReadAlbums(); // read all albums bool found = false; int id = 0; if (albums.Any(a => a.Id == album.Id)) { found = true; id = album.Id; } Assert.IsTrue(found); // check if it was inserted Album b = manager.ReadAlbumById(id); Assert.AreEqual(id, b.Id); Assert.AreEqual(album.Name, b.Name); Assert.AreEqual(album.ReleaseYear, b.ReleaseYear); List<Album> listAlbums = new List<Album>(); List<int> lId = new List<int>(); for (int i = 0; i < 10; i++) { Album a = new Album(FakeId, name + ":" + i, i + 1986); listAlbums.Add(a); } manager.InsertAlbum(listAlbums); /*Insert a list of albums*/ foreach (Album item in listAlbums) { Assert.AreNotEqual(FakeId, item.Id); lId.Add(item.Id); } List<Album> readAlbums = manager.ReadAlbums(); /*read all albums*/ List<int> lReadIds = readAlbums.Select(a => a.Id).ToList(); foreach (int i in lId) { Assert.AreEqual(true, lReadIds.Contains(i)); } }