private async Task TestCodeGenerationCase(ClassUpdateTestCase test, LanguageVersion languageVersion)
        {
            Task <string> sourceTask = File.ReadAllTextAsync(test.SourceFileName);

            Task <string?> expectedTask = Task.FromResult <string?>(null);

            if (File.Exists(test.ExpectedFileName))
            {
                expectedTask = File.ReadAllTextAsync(test.ExpectedFileName);
            }

            string source = await sourceTask.ConfigureAwait(false);

            var result = await _mocklisClassUpdater.UpdateMocklisClass(source, languageVersion).ConfigureAwait(false);

            string?expected = (await expectedTask.ConfigureAwait(false))?.Replace("[VERSION]", _version);

            // Create the 'expected' file if it isn't there. Empty out to recreate.
            if (string.IsNullOrWhiteSpace(expected))
            {
#if NCRUNCH
                var    folder = Environment.GetEnvironmentVariable("MockGeneratorTestsFolder");
                string expectedFilePathInSourceCode =
                    folder == null ? null : Path.Combine(folder, test.TestCaseFolder, test.TestCase + ".Expected.cs");
#else
                string expectedFilePathInSourceCode =
                    Path.Combine(test.PathToTestCases, "..", "..", "..", test.TestCaseFolder, test.TestCase + ".Expected.cs");
#endif

                if (expectedFilePathInSourceCode != null)
                {
                    await File.WriteAllTextAsync(expectedFilePathInSourceCode, result.Code.Replace(_version, "[VERSION]")).ConfigureAwait(false);

                    expected = result.Code;
                }
            }

            try
            {
                Assert.Equal(expected, result.Code);
            }
            catch (Xunit.Sdk.EqualException ex)
            {
                if (!result.IsSuccess)
                {
                    _testOutputHelper.WriteLine(ex.Message);
                    _testOutputHelper.WriteLine(string.Empty);
                }
                else
                {
                    throw;
                }
            }

            if (!result.IsSuccess)
            {
                foreach (var error in result.Errors)
                {
                    _testOutputHelper.WriteLine(error.ErrorText);
                    _testOutputHelper.WriteLine(string.Empty);
                    foreach (var line in error.MarkedCodeLines())
                    {
                        _testOutputHelper.WriteLine(line);
                    }

                    _testOutputHelper.WriteLine(string.Empty);
                }

                throw new Exception("Compilation failed...");
            }
        }
 public async Task TestMocklisClassUpdaterForCSharp8(ClassUpdateTestCase test)
 {
     await TestCodeGenerationCase(test, LanguageVersion.CSharp8);
 }