diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUsersCommand.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUsersCommand.cs index 667e18bcf8..4fc0419020 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUsersCommand.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUsersCommand.cs @@ -35,6 +35,7 @@ public class InviteOrganizationUsersCommand(IEventService eventService, public const string IssueNotifyingOwnersOfSeatLimitReached = "Error encountered notifying organization owners of seat limit reached."; public const string FailedToInviteUsers = "Failed to invite user(s)."; + public const string NoUsersToInvite = "No users to invite."; public async Task> InviteScimOrganizationUserAsync(OrganizationUserSingleEmailInvite request) { @@ -78,7 +79,7 @@ public class InviteOrganizationUsersCommand(IEventService eventService, if (invitesToSend.Length == 0) { - return new Success>([]); + return new Failure>(NoUsersToInvite); } var validationResult = await inviteUsersValidation.ValidateAsync(new InviteUserOrganizationValidationRequest diff --git a/src/Core/Models/Commands/CommandResult.cs b/src/Core/Models/Commands/CommandResult.cs index d775289b8f..3b7ae6915a 100644 --- a/src/Core/Models/Commands/CommandResult.cs +++ b/src/Core/Models/Commands/CommandResult.cs @@ -37,7 +37,7 @@ public class Success(T value) : CommandResult public class Failure(IEnumerable errorMessages) : CommandResult { - public List ErrorMessages { get; } = []; + public List ErrorMessages { get; } = errorMessages.ToList(); public string ErrorMessage => string.Join(" ", ErrorMessages); diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs index 9b6e6ba08a..53db502cb9 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs @@ -58,7 +58,8 @@ public class InviteOrganizationUserCommandTests var result = await sutProvider.Sut.InviteScimOrganizationUserAsync(request); // Assert - Assert.IsType>(result); + Assert.IsType>(result); + Assert.Equal(InviteOrganizationUsersCommand.NoUsersToInvite, (result as Failure).ErrorMessage); await sutProvider.GetDependency() .DidNotReceiveWithAnyArgs()