public function testLoadsBlackoutSeriesByBlackoutId() { $id = 19191; $seriesId = 110101; $ownerId = 919199; $title = 'title'; $description = 'description'; $tz = 'UTC'; $repeatType = RepeatType::Daily; $repeatDaily = new RepeatDaily(1, Date::Parse('2013-04-15', $tz)); $b1Start = Date::Parse('2013-04-14 12:30:00', $tz); $b1End = Date::Parse('2013-04-14 13:30:00', $tz); $series = new BlackoutSeriesRow(); $series->With($seriesId, $ownerId, $title, $repeatType, $repeatDaily->ConfigurationString(), $b1Start, $b1End); $instances = new BlackoutInstanceRow(); $instances->With($seriesId, 1, $b1Start->ToDatabase(), $b1End->ToDatabase()); $instances->With($seriesId, 2, Date::Parse('2013-04-15 12:30:00', $tz)->ToDatabase(), Date::Parse('2013-04-15 13:30:00', $tz)->ToDatabase()); $resources = new BlackoutResourceRow(); $resources->With(1, 'r1', 2, 3, 4); $resources->With(2, 'r2', 4); $this->db->SetRow(0, $series->Rows()); $this->db->SetRow(1, $instances->Rows()); $this->db->SetRow(2, $resources->Rows()); $loadBlackoutCommand = new GetBlackoutSeriesByBlackoutIdCommand($id); $loadBlackoutInstancesCommand = new GetBlackoutInstancesCommand($seriesId); $loadBlackoutResourcesCommand = new GetBlackoutResourcesCommand($seriesId); $series = $this->repository->LoadByBlackoutId($id); $this->assertEquals($loadBlackoutCommand, $this->db->_Commands[0]); $this->assertTrue($this->db->ContainsCommand($loadBlackoutInstancesCommand)); $this->assertTrue($this->db->ContainsCommand($loadBlackoutResourcesCommand)); $this->assertEquals($seriesId, $series->Id()); $this->assertEquals($ownerId, $series->OwnerId()); $this->assertEquals($title, $series->Title()); $this->assertEquals($repeatType, $series->RepeatType()); $this->assertEquals($repeatDaily->ConfigurationString(), $series->RepeatConfigurationString()); $this->assertEquals(2, count($series->AllBlackouts())); $instances = $series->AllBlackouts(); $this->assertEquals($b1Start, $instances[0]->StartDate()); $this->assertEquals($b1End, $instances[0]->EndDate()); $this->assertEquals(count($resources->Rows()), count($series->Resources())); $this->assertEquals($b1Start, $series->CurrentBlackout()->StartDate()); }