public async Task AbortOnNotFoundRequests() { var mockMediator = new Mock<IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List<string> { "7" } }); Assert.False(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task AbortOnNotFoundItinerary() { var mockMediator = new Mock <IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = 7 }); Assert.False(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task AbortOnNotFoundItinerary() { var mockMediator = new Mock<IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = 7 }); Assert.False(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task AbortOnNotFoundRequests() { var mockMediator = new Mock <IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List <string> { "7" } }); Assert.False(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task NotAlterTheAlreadyAssignedRequests() { var mockMediator = new Mock<IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List<string> { _assignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task NotAlterTheAlreadyAssignedRequests() { var mockMediator = new Mock <IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List <string> { _assignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Empty(Context.ItineraryRequests); }
public async Task AssignRequestsToTheItinerary() { var mockMediator = new Mock <IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List <string> { _notAssignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Equal(RequestStatus.Assigned, _notAssignedRequest.Status); Assert.Equal(1, Context.ItineraryRequests.Count()); Assert.Equal(1, Context.ItineraryRequests.First().OrderIndex); Assert.Equal(_theItinerary.Id, Context.ItineraryRequests.First().ItineraryId); Assert.Equal(_notAssignedRequest.RequestId, Context.ItineraryRequests.First().RequestId); }
public async Task MaintainTheOrderingOfTheItineraryRequests() { var mockMediator = new Mock <IMediator>(); Context.ItineraryRequests.Add(new ItineraryRequest { OrderIndex = 1, ItineraryId = _theItinerary.Id }); Context.SaveChanges(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List <string> { _notAssignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Equal(2, Context.ItineraryRequests.Count()); Assert.True(Context.ItineraryRequests.Any(ir => ir.OrderIndex == 2)); }
public async Task AssignRequestsToTheItinerary() { var mockMediator = new Mock<IMediator>(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List<string> { _notAssignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Equal(RequestStatus.Assigned, _notAssignedRequest.Status); Assert.Equal(1, Context.ItineraryRequests.Count()); Assert.Equal(1, Context.ItineraryRequests.First().OrderIndex); Assert.Equal(_theItinerary.Id, Context.ItineraryRequests.First().ItineraryId); Assert.Equal(_notAssignedRequest.RequestId, Context.ItineraryRequests.First().RequestId); }
public async Task MaintainTheOrderingOfTheItineraryRequests() { var mockMediator = new Mock<IMediator>(); Context.ItineraryRequests.Add(new ItineraryRequest { OrderIndex = 1, ItineraryId = _theItinerary.Id }); Context.SaveChanges(); var handler = new AddRequestsCommandHandlerAsync(Context, mockMediator.Object); bool succeded = await handler.Handle(new AddRequestsCommand { ItineraryId = _theItinerary.Id, RequestIdsToAdd = new List<string> { _notAssignedRequest.RequestId.ToString() } }); Assert.True(succeded); Assert.Equal(2, Context.ItineraryRequests.Count()); Assert.True(Context.ItineraryRequests.Any(ir => ir.OrderIndex == 2)); }