private async Task CreateProfileFuzzTestRunnerAsync(IUserProfileServices creator, IUserProfileNamedPipeFactory pipeFactory, string input, int serverTimeOut, int clientTimeOut)
        {
            var task = Task.Run(async() => {
                try {
                    await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                } catch (JsonReaderException) {
                    // expecting JSON parsing to fail
                    // JSON parsing may fail due to randomly generated strings as input.
                }
            });

            using (var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                var result = await CreateProfileClientTestWorkerAsync(input, cts.Token);

                // fuzz test parsing succeeded, the creator always fails for this test.
                result?.Error.Should().Be(13);
            }

            await ParallelTools.When(task, serverTimeOut + clientTimeOut);
        }
        private async Task CreateProfileTestRunnerAsync(IUserProfileServices creator, IUserProfileNamedPipeFactory pipeFactory, string input, bool isValidParse, bool isValidAccount, bool isExistingAccount, int serverTimeOut, int clientTimeOut)
        {
            var testDone = new ManualResetEventSlim(false);

            Task.Run(async() => {
                try {
                    if (isValidParse)
                    {
                        Func <Task> f = async() => await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                        f.ShouldNotThrow();
                    }
                    else
                    {
                        Func <Task> f = () => RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                        await f.ShouldThrowAsync <Exception>();
                    }
                } finally {
                    testDone.Set();
                }
            }).DoNotWait();

            using (var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                var result = await CreateProfileClientTestWorkerAsync(input, cts.Token);

                if (isValidParse)
                {
                    result.Error.Should().Be((uint)(isValidAccount ? 0 : 13));
                    result.ProfileExists.Should().Be(isExistingAccount);
                }
                else
                {
                    result.Should().BeNull();
                }
            }

            testDone.Wait(serverTimeOut + clientTimeOut);
        }