public async void CreateActivity_NewActivityWithNewType_ShouldNotThrow() { // Arrange _activityTypeRepoMock.Setup(repo => repo.GetActivityTypeAsync(It.IsAny <long>(), It.IsAny <string>())) .Returns(Task.FromResult((ActivityTypeDbModel)null)); _activityRepoMock.Setup(repo => repo.GetActivityAsync(It.IsAny <long>(), It.IsAny <string>(), It.IsAny <long>())) .Returns(Task.FromResult((ActivityDbModel)null)); var activity = new Activity(Mocks.Activity) { Id = null }; activity.Type.Id = null; // Act Task act() => _target.CreateActivityAsync(Mocks.Activity); // Assert await act(); _unitOfWorkMock.Verify(uow => uow.SaveAsync(), Times.Once); }
public override async Task <ActivityResponse> CreateActivity(Activity activity, ServerCallContext context) { try { var createdActivity = await _activityManager.CreateActivityAsync(activity); return(new ActivityResponse { Message = $"Successfully created new activity: {createdActivity?.Name}", Status = ResponseStatus.Success }); } catch (Exception ex) { return(new ActivityResponse { Message = $"Failed to create new activity: Activity = {JsonConvert.SerializeObject(activity)}, Error = {ex.Message}", Status = ResponseStatus.Failed }); } }