Exemple #1
0
        public override async Task <ActivityResponse> EditActivity(Activity activity, ServerCallContext context)
        {
            try
            {
                var editedActivity = await _activityManager.EditActivityAsync(activity);

                return(new ActivityResponse
                {
                    Message = $"Successfully updated activity: {editedActivity.Name}",
                    Status = ResponseStatus.Success
                });
            }
            catch (Exception ex)
            {
                return(new ActivityResponse
                {
                    Message = $"Failed to update given activity: ActivityId = {activity.Id}, Error = {ex.Message}",
                    Status = ResponseStatus.Failed
                });
            }
        }
Exemple #2
0
        public async void EditActivity_ForValidArg_ShouldPassValidArg()
        {
            // Arrange
            var activityModel = _mapper.Map <ActivityDbModel>(Mocks.Activity);

            _activityRepoMock.Setup(repo => repo.Update(It.IsAny <ActivityDbModel>()));

            // Act
            await _target.EditActivityAsync(Mocks.Activity);

            // Assert
            _unitOfWorkMock.Verify(uow => uow.SaveAsync(), Times.Once);
            _activityRepoMock.Verify(repo => repo.Update(It.Is <ActivityDbModel>(m =>
                                                                                 m.Address == activityModel.Address &&
                                                                                 m.Currency == activityModel.Currency &&
                                                                                 m.ChangeUser == activityModel.ChangeUser &&
                                                                                 m.ContactName == activityModel.ContactName &&
                                                                                 m.EmailAddress == activityModel.EmailAddress &&
                                                                                 m.ActivityTypeId == activityModel.ActivityTypeId &&
                                                                                 m.ActivityType.Id == activityModel.ActivityType.Id &&
                                                                                 m.ActivityType.Name == activityModel.ActivityType.Name &&
                                                                                 m.ActivityType.AgencyId == activityModel.ActivityType.AgencyId)), Times.Once);
        }