コード例 #1
0
ファイル: PerformanceDao.cs プロジェクト: Pham0uz/UFO
        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.");
        }
コード例 #2
0
ファイル: PerformanceVM.cs プロジェクト: Pham0uz/UFO
 public PerformanceVM(Performance performance)
 {
     this.performance = performance;
 }
コード例 #3
0
ファイル: PerformanceDao.cs プロジェクト: Pham0uz/UFO
 public bool Update(Performance p)
 {
     return database.ExecuteNonQuery(CreateUpdateCommand(p.Date, p.Time, p.Artist, p.Venue)) == 1;
 }
コード例 #4
0
ファイル: Commander.cs プロジェクト: Pham0uz/UFO
 public bool DeletePerformance(Performance performance)
 {
     return performanceDao.Delete(performance.Date, performance.Time, performance.Venue);
 }
コード例 #5
0
ファイル: Commander.cs プロジェクト: Pham0uz/UFO
 public bool UpdatePerformance(Performance performance)
 {
     if (PerformanceIsPossible(performance))
         return performanceDao.Update(performance);
     return false;
 }
コード例 #6
0
ファイル: Commander.cs プロジェクト: Pham0uz/UFO
        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;
        }
コード例 #7
0
ファイル: Commander.cs プロジェクト: Pham0uz/UFO
 public bool InsertPerformance(Performance performance)
 {
     if (PerformanceIsPossible(performance))
         return performanceDao.Insert(performance);
     return false;
 }