public void CheckResults()

in GoogleTestAdapter/Tests.Common/ResultChecker/ResultChecker.cs [23:61]


        public void CheckResults(string testResults, string typeName, [CallerMemberName] string testCaseName = null)
        {
            string expectationFile = Path.Combine(_goldenFilesDirectory, TestResources.GetGoldenFileName(typeName, testCaseName, _fileExtension));
            string resultFile = Path.Combine(_testErrorsDirectory, TestResources.GetGoldenFileName(typeName, testCaseName, _fileExtension));

            if (!File.Exists(expectationFile))
            {
                File.WriteAllText(expectationFile, testResults);
                Assert.Inconclusive("This is the first time this test runs.");
            }

            string expectedResult = File.ReadAllText(expectationFile);
            string msg;
            bool stringsAreEqual = AreEqual(expectedResult, testResults, out msg);
            if (!stringsAreEqual)
            {
#pragma warning disable CS0162 // Unreachable code (because overwriteTestResults is compile time constant)
                // ReSharper disable HeuristicUnreachableCode
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                if (TestMetadata.OverwriteTestResults)
                {
                    File.WriteAllText(expectationFile, testResults);
                    Assert.Inconclusive("Test results changed and have been overwritten. Differences: " + msg);
                }
                else
                {
                    // ReSharper disable once AssignNullToNotNullAttribute
                    Directory.CreateDirectory(Path.GetDirectoryName(resultFile));
                    File.WriteAllText(resultFile, testResults);
                    Assert.Fail("Test result doesn't match expectation. Result written to: " + resultFile + ". Differences: " + msg);
                }
                // ReSharper restore HeuristicUnreachableCode
#pragma warning restore CS0162
            }
            else if (File.Exists(resultFile))
            {
                File.Delete(resultFile);
            }
        }