Exemple #1
0
 public void ActivityDoesNotExist()
 {
     var context = ServiceProvider.GetService<AllReadyContext>();
     var query = new DeleteActivityCommand { ActivityId = 0 };
     var handler = new DeleteActivityCommandHandler(context);
     var result = handler.Handle(query);
 }
 public void ActivityIsDeleted()
 {
     const int activityId = 1;
     var sut = new DeleteActivityCommandHandler(Context);
     sut.Handle(new DeleteActivityCommand { ActivityId = activityId });
     Assert.False(Context.Activities.Any(t => t.Id == activityId));
 }
 public void ActivityDoesNotExist()
 {
     var context = ServiceProvider.GetService<AllReadyContext>();
     var command = new DeleteActivityCommand { ActivityId = 0 };
     var handler = new DeleteActivityCommandHandler(context);
     handler.Handle(command);
     //TODO: this test needs to be completed to actually test something
 }
Exemple #4
0
 public void ActivityDoesNotExist()
 {
     var context = ServiceProvider.GetService <AllReadyContext>();
     var query   = new DeleteActivityCommand {
         ActivityId = 0
     };
     var handler = new DeleteActivityCommandHandler(context);
     var result  = handler.Handle(query);
 }
        public void NonExistantTaskDoesNotCauseException()
        {
            var sut = new DeleteActivityCommandHandler(Context);

            sut.Handle(new DeleteActivityCommand {
                ActivityId = 666
            });
            Assert.False(Context.Activities.Any(t => t.Id == ActivityId));
        }
        public void ActivityIsDeleted()
        {
            var sut = new DeleteActivityCommandHandler(Context);

            sut.Handle(new DeleteActivityCommand {
                ActivityId = ActivityId
            });
            Assert.False(Context.Activities.Any(t => t.Id == ActivityId));
        }
Exemple #7
0
        public void ExistingActivity()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            var query = new DeleteActivityCommand { ActivityId = 1 };
            var handler = new DeleteActivityCommandHandler(context);
            var result = handler.Handle(query);

            var data = context.Activities.Count(_ => _.Id == 1);
            Assert.Equal(0, data);
        }
        public void ActivityDoesNotExist()
        {
            var context = ServiceProvider.GetService <AllReadyContext>();
            var command = new DeleteActivityCommand {
                ActivityId = 0
            };
            var handler = new DeleteActivityCommandHandler(context);

            handler.Handle(command);
            //TODO: this test needs to be completed to actually test something
        }
        public async Task Handle_ActivityIdNotExists_ThrowsNotFoundApplicationException()
        {
            var dbName = $"{nameof(DeleteActivityCommandHandlerTests)}_{nameof(Handle_ActivityIdNotExists_ThrowsNotFoundApplicationException)}";

            using var context = TestApplicationDbContext.Create(dbName);
            var handler           = new DeleteActivityCommandHandler(context);
            var request           = new DeleteActivityCommand(1);
            var cancellationToken = new CancellationToken();

            Task <Unit> action() => handler.Handle(request, cancellationToken);

            await Assert.ThrowsAsync <NotFoundApplicationException>(action);
        }
Exemple #10
0
        public void ExistingActivity()
        {
            var context = ServiceProvider.GetService <AllReadyContext>();
            var query   = new DeleteActivityCommand {
                ActivityId = 1
            };
            var handler = new DeleteActivityCommandHandler(context);
            var result  = handler.Handle(query);

            var data = context.Activities.Count(_ => _.Id == 1);

            Assert.Equal(0, data);
        }
        public async Task Handle_ActivityIdExists_DeletesActivity()
        {
            var dbName = $"{nameof(DeleteActivityCommandHandlerTests)}_{nameof(Handle_ActivityIdExists_DeletesActivity)}";

            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 DeleteActivityCommandHandler(context);
            var request = new DeleteActivityCommand(1);
            await handler.Handle(request, cancellationToken);

            var activityFromDb = await context.Activities.FirstOrDefaultAsync(a => a.Id == 1);

            Assert.Null(activityFromDb);
        }
 public void NonExistantTaskDoesNotCauseException()
 {
     var sut = new DeleteActivityCommandHandler(Context);
     sut.Handle(new DeleteActivityCommand { ActivityId = 666 });
     Assert.False(Context.Activities.Any(t => t.Id == ActivityId));
 }