public void TestInsert() { // arrange bool expectedValue = true; Performance newPerformance = new Performance(new DateTime(2015, 7, 23), 19, "MadMatt", "T2"); bool beforeInsert = pDao.GetAll().Count == 5; // act pDao.Insert(newPerformance); bool afterInsert = pDao.GetAll().Count == 6; // assert bool actualValue = (beforeInsert && afterInsert); Assert.AreEqual(expectedValue, actualValue, "Performance has not been inserted successfully."); }
public PerformanceVM(Performance performance) { this.performance = performance; }
public bool Update(Performance p) { return database.ExecuteNonQuery(CreateUpdateCommand(p.Date, p.Time, p.Artist, p.Venue)) == 1; }
public bool DeletePerformance(Performance performance) { return performanceDao.Delete(performance.Date, performance.Time, performance.Venue); }
public bool UpdatePerformance(Performance performance) { if (PerformanceIsPossible(performance)) return performanceDao.Update(performance); return false; }
public bool PerformanceIsPossible(Performance performance) { foreach (Performance p in GetPerformancesByDate(performance.Date)) { // at least 1 hour break if (p.Time == performance.Time - 1 || p.Time == performance.Time + 1) if (p.Artist == performance.Artist) return false; // can't have 2 performances simultaneously if (p.Time == performance.Time && p.Artist == performance.Artist) return false; } return true; }
public bool InsertPerformance(Performance performance) { if (PerformanceIsPossible(performance)) return performanceDao.Insert(performance); return false; }