public async Task InvokeUpdateTaskSignupAsyncWithTheCorrectParametersForEachTaskSignupViewModelOnCommand()
        {
            var user                 = new ApplicationUser();
            var dateTimeUtcNow       = DateTime.UtcNow;
            var taskSignupViewModels = new List <TaskSignupViewModel>
            {
                new TaskSignupViewModel {
                    Id = 1, StatusDescription = "statusDescription1", Status = "Status1", TaskId = 1,
                }
            };

            var message = new UpdateMyTasksCommandAsync {
                TaskSignups = taskSignupViewModels
            };

            var dataAccess = new Mock <IAllReadyDataAccess>();

            dataAccess.Setup(x => x.GetUser(It.IsAny <string>())).Returns(user);

            var sut = new UpdateMyTasksHandlerAsync(dataAccess.Object)
            {
                DateTimeUtcNow = () => dateTimeUtcNow
            };
            await sut.Handle(message);

            dataAccess.Verify(x => x.UpdateTaskSignupAsync(It.Is <TaskSignup>(y =>
                                                                              y.Id == taskSignupViewModels[0].Id &&
                                                                              y.StatusDateTimeUtc == dateTimeUtcNow &&
                                                                              y.StatusDescription == taskSignupViewModels[0].StatusDescription &&
                                                                              y.Status == taskSignupViewModels[0].Status &&
                                                                              y.Task.Id == taskSignupViewModels[0].TaskId &&
                                                                              y.User == user)));
        }
Beispiel #2
0
        public async Task CanSaveZeroTasks()
        {
            var options = this.CreateNewContextOptions();

            const string userId = "1";
            var          user   = new ApplicationUser()
            {
                Id = userId
            };

            using (var context = new AllReadyContext(options)) {
                context.Users.Add(user);
                await context.SaveChangesAsync();
            }

            var message = new UpdateMyTasksCommandAsync {
                UserId = userId, TaskSignups = new List <TaskSignupViewModel>()
            };

            using (var context = new AllReadyContext(options)) {
                var sut = new UpdateMyTasksHandlerAsync(context);
                await sut.Handle(message);
            }

            using (var context = new AllReadyContext(options)) {
                var taskSignups = context.TaskSignups.Count();
                Assert.Equal(taskSignups, 0);
            }
        }
        public async Task InvokeGetUserWithTheCorrectUserId()
        {
            var message = new UpdateMyTasksCommandAsync {
                UserId = "1", TaskSignups = new List <TaskSignupViewModel>()
            };
            var dataAccess = new Mock <IAllReadyDataAccess>();
            var sut        = new UpdateMyTasksHandlerAsync(dataAccess.Object);
            await sut.Handle(message);

            dataAccess.Verify(x => x.GetUser(message.UserId), Times.Once);
        }
Beispiel #4
0
        public async Task InvokeUpdateTaskSignupAsyncWithTheCorrectParametersForEachTaskSignupViewModelOnCommand()
        {
            var options = this.CreateNewContextOptions();

            const string userId       = "1";
            const int    taskSignupId = 1;
            var          user         = new ApplicationUser()
            {
                Id = userId
            };
            var dateTimeUtcNow       = DateTime.UtcNow;
            var taskSignupViewModels = new List <TaskSignupViewModel>
            {
                new TaskSignupViewModel {
                    Id = taskSignupId, StatusDescription = "statusDescription1", Status = "Status1", TaskId = 1,
                }
            };

            var message = new UpdateMyTasksCommandAsync {
                TaskSignups = taskSignupViewModels, UserId = userId
            };

            using (var context = new AllReadyContext(options)) {
                context.Users.Add(user);
                context.TaskSignups.Add(new TaskSignup {
                    Id = taskSignupId
                });
                context.Tasks.Add(new AllReadyTask {
                    Id = 1
                });
                await context.SaveChangesAsync();
            }

            using (var context = new AllReadyContext(options)) {
                var sut = new UpdateMyTasksHandlerAsync(context)
                {
                    DateTimeUtcNow = () => dateTimeUtcNow
                };
                await sut.Handle(message);
            }

            using (var context = new AllReadyContext(options)) {
                var signup = context.TaskSignups.FirstOrDefault(x => x.Id == taskSignupId);
                Assert.Equal(signup != null, true);
            }
        }