public void ShouldNotCallHandleIfUserNotExist()
        {
            identityService.Setup(x => x.GetUserByUsernameAsync(user.UserName)).Returns(Task.FromResult((AppUser)null));

            AddRoleToUserCommandHandler addRoleToUserCommandHandler = new AddRoleToUserCommandHandler(identityService.Object, roleManager.Object, stringLocalizer.Object);
            AddRoleToUserCommand        addRoleToUserCommand        = new AddRoleToUserCommand(userDto);

            Func <Task> act = async() => await addRoleToUserCommandHandler.Handle(addRoleToUserCommand, new CancellationToken());

            act.Should().Throw <NotFoundException>();
        }
        public async Task ShouldCallHandle()
        {
            identityService.Setup(x => x.GetUserByUsernameAsync(user.UserName)).Returns(Task.FromResult(user));

            AddRoleToUserCommandHandler addRoleToUserCommandHandler = new AddRoleToUserCommandHandler(identityService.Object, roleManager.Object, stringLocalizer.Object);
            AddRoleToUserCommand        addRoleToUserCommand        = new AddRoleToUserCommand(userDto);

            roleManager.Setup(x => x.RoleExistsAsync(addRoleToUserCommand.Role)).Returns(Task.FromResult(true));
            identityService.Setup(x => x.AddRoleToUserAsync(user, addRoleToUserCommand.Role)).Returns(Task.FromResult(Result.Success()));

            var result = await addRoleToUserCommandHandler.Handle(addRoleToUserCommand, new CancellationToken());

            result.Succeeded.Should().BeTrue();
        }