public async Task <Guid> AddGroup(AddGroupCommand command, CancellationToken cancellationToken)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            command.EnsureIsValid();

            var groupPersisted = await authorizationRepository.GetGroupBy(command.Name, command.Domain, cancellationToken).ConfigureAwait(false);

            if (groupPersisted is not null)
            {
                throw new BusinessException(Messages.GroupAlreadyExist);
            }

            var group = new Group()
            {
                Name        = command.Name,
                Description = command.Description,
                Domain      = command.Domain
            };

            await authorizationRepository.AddGroup(group, cancellationToken).ConfigureAwait(false);

            return(group.Id);
        }
        public async Task AddGroup_Throw_Exception_If_Group_Already_Exist()
        {
            var group = new Group()
            {
                Name = "AllowGet", Domain = "user", Description = "Group of users"
            };

            var command = new AddGroupCommand(group.Name, group.Domain, group.Description);

            authorizationRepositoryMock.GetGroupBy(command.Name, command.Domain, Arg.Any <CancellationToken>())
            .Returns(group);

            Assert.ThrowsAsync <BusinessException>(async() =>
                                                   await authorizationAppService.AddGroup(command, CancellationToken.None), "Group already exist.");

            await authorizationRepositoryMock.Received(1).GetGroupBy(command.Name, command.Domain,
                                                                     Arg.Any <CancellationToken>());
        }