public async Task throws_when_aggregate_not_found(CreateCalendarItemCommand createCommand, DeleteCalendarItemCommand deleteCommand) { createCommand.EndDate = createCommand.StartDate.AddDays(1); await CreateCommandHandler.HandleAsync(createCommand); var exception = await Record.ExceptionAsync(() => act(deleteCommand)); exception.ShouldBeOfType(typeof(AwesomeCalendarException)); }
public void sets_correct_calendar_item_properties(CreateCalendarItemCommand command) { act(command); Assert.Equal(command.Id, CalendarItem.Id); Assert.Equal(command.Name, CalendarItem.Name); Assert.Equal(command.UserId, CalendarItem.UserId); Assert.Equal(command.Description, CalendarItem.Description); Assert.Equal(command.StartDate, CalendarItem.StartDate); Assert.Equal(command.EndDate, CalendarItem.EndDate); }
public void sets_correct_calendar_item_cycles_properties(CreateCalendarItemCommand command) { act(command); var commandItemCycle = command.Cycles.First(); var calendarItemCycle = CalendarItem.Cycles.First(); Assert.Equal(commandItemCycle.Interval, calendarItemCycle.Interval); Assert.Equal(commandItemCycle.Type, calendarItemCycle.Type); Assert.Equal(commandItemCycle.StartDate, calendarItemCycle.StartDate); Assert.Equal(commandItemCycle.EndDate, calendarItemCycle.EndDate); }
public async Task throws_when_command_has_invalid_data(string userId, string name, DateTime startDate, DateTime endDate) { var command = new CreateCalendarItemCommand { UserId = userId, Name = name, StartDate = startDate, EndDate = endDate }; var exception = await Record.ExceptionAsync(async() => await act(command)); exception.ShouldBeOfType(typeof(AwesomeCalendarException)); Assert.Equal(((AwesomeCalendarException)exception).Type, AwesomeCalendarExceptionType.InvalidCommand); }
public void creates_proper_number_of_events_on_creating(CreateCalendarItemCommand command) { act(command); Assert.Equal(command.Cycles.Count() + 1, CalendarItem.GetUncommittedEvents().Count); }
void act(CreateCalendarItemCommand command) { CalendarItem = new CalendarItem(command.Id, command.UserId, command.Name, command.Description, command.StartDate, command.EndDate, command.Cycles); }
public async Task persists_event_to_event_store_needed_to_reconstruct_calendar_item(CreateCalendarItemCommand command) { command.StartDate = DateTime.UtcNow; command.EndDate = DateTime.UtcNow.AddHours(1); await act(command); var createdAggreagte = await EventStore.GetByIdAsync <CalendarItem>(command.Id); createdAggreagte.ShouldBeOfType(typeof(CalendarItem)); Assert.Equal(command.Id, createdAggreagte.Id); }
async Task act(CreateCalendarItemCommand command) { await CommandHandler.HandleAsync(command); }