public async Task Handle_ActivityIdAndCardIdExist_SetsActivityOrderToNull() { var dbName = $"{nameof(MoveActivityToCardCommandHandlerTests)}_{nameof(Handle_ActivityIdAndCardIdExist_SetsActivityOrderToNull)}"; using var context = TestApplicationDbContext.Create(dbName); var cancellationToken = new CancellationToken(); var card1 = Card.Create("card1-title"); var card2 = Card.Create("card2-title"); var activity = Activity.Create("activity-title", 1); card1.AddActivity(activity); context.Cards.AddRange(card1, card2); await context.SaveChangesAsync(cancellationToken); var handler = new MoveActivityToCardCommandHandler(context); var request = new MoveActivityToCardCommand { ActivityId = activity.Id, CardId = card2.Id }; await handler.Handle(request, cancellationToken); var activityFromDb = await context.Activities.FirstOrDefaultAsync(a => a.Id == activity.Id, cancellationToken); Assert.Null(activityFromDb.Order); }
public async Task Handle_CardIdNotExists_ThrowsNotFoundApplicationException() { var dbName = $"{nameof(MoveActivityToCardCommandHandlerTests)}_{nameof(Handle_CardIdNotExists_ThrowsNotFoundApplicationException)}"; using var context = TestApplicationDbContext.Create(dbName); var cancellationToken = new CancellationToken(); var activity = Activity.Create("activity-title"); context.Activities.Add(activity); await context.SaveChangesAsync(cancellationToken); var handler = new MoveActivityToCardCommandHandler(context); var request = new MoveActivityToCardCommand { ActivityId = 1, CardId = 1 }; Task <Unit> action() => handler.Handle(request, cancellationToken); await Assert.ThrowsAsync <NotFoundApplicationException>(action); }