Пример #1
0
 public void Cancel(string reason)
 {
     if (_cancelled)
     {
         throw new InvalidOperationException("The concert has already been cancelled.");
     }
     Apply(ConcertEvents.Cancelled(_id, reason));
 }
Пример #2
0
 public void CancelledConcertCanNotBeCancelled()
 {
     new CommandScenarioFor <Concert>(Concert.Factory).
     Given(
         ConcertEvents.Planned(ConcertId),
         ConcertEvents.Cancelled(ConcertId, "Guitars all smashed.")).
     When(sut => sut.Cancel("Lead singer OD'ed.")).
     AssertThrows(new InvalidOperationException("The concert has already been cancelled."));
 }
Пример #3
0
 public void PlannedConcertCanBeCancelled()
 {
     new CommandScenarioFor <Concert>(Concert.Factory).
     Given(
         ConcertEvents.Planned(ConcertId)).
     When(sut => sut.Cancel("Lead singer OD'ed.")).
     Then(
         ConcertEvents.Cancelled(ConcertId, "Lead singer OD'ed.")).
     Assert();
 }
Пример #4
0
 public void CancelledConcertCanNotStartTicketSale()
 {
     new FactoryScenarioFor <Concert>(Concert.Factory).
     Given(
         ConcertEvents.Planned(ConcertId),
         ConcertEvents.Cancelled(ConcertId, "Lead singer OD'ed.")).
     When(sut => sut.StartTicketSale(TicketSaleId, DateTimeOffset.UtcNow.Date)).
     AssertThrows(
         new InvalidOperationException("Starting a ticket sale for a cancelled concert is impossible."));
 }