Ejemplo n.º 1
0
        public async Task <TestResult> RunTestAsync(string assemblyPath, CancellationToken cancellationToken)
        {
            var contentFile = _contentUtil.GetTestResultContentFile(assemblyPath);
            var builder     = new StringBuilder();

            builder.AppendLine($"{Path.GetFileName(assemblyPath)} - {contentFile.Checksum}");
            builder.AppendLine("===");
            builder.AppendLine(contentFile.Content);
            builder.AppendLine("===");
            Logger.Log(builder.ToString());

            TestResult testResult;

            if (!_dataStorage.TryGetTestResult(contentFile.Checksum, out testResult))
            {
                Logger.Log($"{Path.GetFileName(assemblyPath)} - running");
                testResult = await _testExecutor.RunTestAsync(assemblyPath, cancellationToken);

                Logger.Log($"{Path.GetFileName(assemblyPath)} - caching");
                _dataStorage.AddTestResult(contentFile, testResult);
            }
            else
            {
                testResult = Migrate(testResult);
                Logger.Log($"{Path.GetFileName(assemblyPath)} - cache hit");
            }

            return(testResult);
        }