public void Cancel(string reason) { if (_cancelled) { throw new InvalidOperationException("The concert has already been cancelled."); } Apply(ConcertEvents.Cancelled(_id, reason)); }
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.")); }
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(); }
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.")); }