public void TestUpdate() { IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = dao.findById(1); artist.Email = "*****@*****.**"; dao.Update(artist); Artist result = dao.findById(1); Assert.AreEqual(result.Email, artist.Email); }
/// <summary> /// disable an artist and set performances after now /// </summary> /// <param name="artist"></param> /// <returns></returns> public bool DeleteArtist(Artist artist) { IArtistDao dao = DALFactory.CreateArtistDao(database); Artist toDelete = dao.findById(artist.Id); if (toDelete == null) { return(false); } toDelete.Deleted = true; bool success = dao.Update(toDelete); if (success) { IPerformanceDao performanceDao = DALFactory.CreatePerformanceDao(database); IList <Performance> performances = performanceDao.FindPerformanceForArtistsAfterDate(toDelete, DateTime.Now); foreach (Performance p in performances) { Console.WriteLine("found performances " + p.Id + "artist " + p.Artist.Name); p.Canceld = true; success = performanceDao.Update(p); } } return(success); }
public IList <Performance> QueryPerfomancesByArtist(int artistId) { IPerformanceDao dao = DALFactory.CreatePerformanceDao(database); IArtistDao artistDao = DALFactory.CreateArtistDao(database); Artist a = artistDao.findById(artistId); return(dao.findByProperty(typeof(Performance).GetProperty("Artist"), a)); }
public void TestFindById() { IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = dao.findById(1); Assert.AreEqual(artist.Id, 1); Assert.AreEqual(artist.Name, "Larry Page"); }
public void TestFindByIdAndCheckFetchCatagory() { IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = dao.findById(1); Assert.AreEqual(artist.Id, 1); Assert.AreEqual(artist.Name, "Larry Page"); ICatagoryDao catDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase()); Catagory cat = catDao.findById(1); Assert.AreEqual(artist.Catagory.Id, cat.Id); }
public void TestUpdate() { IPerformanceDao dao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase()); Performance performance = dao.findById(1); IArtistDao artistDao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = artistDao.findById(2); performance.Artist = artist; performance.StagingTime = DateTime.UtcNow; dao.Update(performance); Performance result = dao.findById(1); //Assert.AreEqual(result.StagingTime, performance.StagingTime); Assert.AreEqual(result.Artist.Id, performance.Artist.Id); }
public void TestInsert() { Performance performance = new Performance(); IArtistDao artistDao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = artistDao.findById(1); IVenueDao venueDao = DALFactory.CreateVenueDao(DALFactory.CreateDatabase()); Venue venue = venueDao.findById(1); performance.Artist = artist; performance.Venue = venue; performance.StagingTime = DateTime.Now; IPerformanceDao dao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase()); dao.Insert(performance); IList <Performance> result = dao.findAll(); Assert.AreEqual(result.Count, 3); }
private static void CreatePerformances() { Console.WriteLine("Insert Performances "); IVenueDao venueDao = DALFactory.CreateVenueDao(DALFactory.CreateDatabase()); IPerformanceDao performanceDao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase()); IArtistDao artistDao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); int year = 2016; int month = 01; int day = 23; for (int i = 0; i < 3; i++) { int count = 1; int hour = 14; int min = 00; int second = 00; for (int j = 1; j <= 40; j++) { count++; if (count == 10) { hour = hour + 2; count = 1; } DateTime dt = new DateTime(year, month, day, hour, min, second); Venue venue = venueDao.findById(j); Artist artist = artistDao.findById(j); Performance p = new Performance(); p.Artist = artist; p.Venue = venue; p.StagingTime = dt; performanceDao.Insert(p); } day++; } }