public void SolutionShouldBeCorrectlyAnalyzed(TestSolution testSolution)
        {
            var analysisRun = TestSolutionAnalyzer.Run(testSolution);

            Assert.Equal(analysisRun.Expected.Status, analysisRun.Actual.Status);
            Assert.Equal(analysisRun.Expected.Comments, analysisRun.Actual.Comments);
        }
        private static TestSolutionAnalysisRun CreateTestSolutionAnalysisRun(TestSolution solution)
        {
            var actualAnalysisResult = TestSolutionActualAnalysisResultReader.Read(solution);

            UpdateExpectedAnalysisResultIfNeeded(solution, actualAnalysisResult);

            var expectedAnalysisResult = TestSolutionExpectedAnalysisResultReader.Read(solution);

            return(new TestSolutionAnalysisRun(expectedAnalysisResult, actualAnalysisResult));
        }
예제 #3
0
        private static TestSolutionAnalysisRun CreateTestSolutionAnalyisRun(TestSolution solution)
        {
            var expectedAnalysisJsonFilePath = Path.Combine(solution.Directory, "expected_analysis.json");
            var actualAnalysisJsonFilePath   = Path.Combine(solution.Directory, "analysis.json");

            var expectedAnalysisResult = TestSolutionAnalysisResultReader.Read(expectedAnalysisJsonFilePath);
            var actualAnalysisResult   = TestSolutionAnalysisResultReader.Read(actualAnalysisJsonFilePath);

            return(new TestSolutionAnalysisRun(expectedAnalysisResult, actualAnalysisResult));
        }
        private static void UpdateExpectedAnalysisResultIfNeeded(TestSolution solution, TestSolutionAnalysisResult actualAnalysisResult)
        {
            if (Options.UpdateAnalysis)
            {
                TestSolutionExpectedAnalysisResultWriter.UpdateExpectedAnalysis(solution, actualAnalysisResult);
            }

            if (Options.UpdateComments)
            {
            }
        }
 private static void RunAnalyzer(TestSolution testSolution)
 {
     if (Options.UseDocker)
     {
         RunAnalyzerUsingDocker(testSolution);
     }
     else
     {
         RunAnalyzerWithoutDocker(testSolution);
     }
 }
        private static string ProjectDirectory(this TestSolution solution)
        {
            bool IsProjectFile(FileInfo file) => file.Name.EndsWith(".csproj");

            var parent = Directory.GetParent(solution.Directory);

            while (!parent.EnumerateFiles().Any(IsProjectFile))
            {
                parent = parent.Parent;
            }

            return(parent.FullName);
        }
 public static string ReadTestFile(this TestSolution solution, string fileName) =>
 File.ReadAllText(Path.Combine(solution.Directory, fileName));
 public static void WriteSourceFile(this TestSolution solution, string fileName, string contents) =>
 File.WriteAllText(Path.Combine(solution.ProjectDirectory(), solution.Directory, fileName), contents);
        public static TestSolutionAnalysisRun Run(TestSolution testSolution)
        {
            RunAnalyzer(testSolution);

            return(CreateTestSolutionAnalysisRun(testSolution));
        }
 private static void RunAnalyzerWithoutDocker(TestSolution testSolution) =>
 Program.Main(new[] { testSolution.Slug, testSolution.DirectoryFullPath, testSolution.DirectoryFullPath });
 private static void RunAnalyzerUsingDocker(TestSolution testSolution) =>
 Process.Start("docker", $"run -v {testSolution.DirectoryFullPath}:/solution -v {testSolution.DirectoryFullPath}:/results exercism/csharp-analyzer {testSolution.Slug} /solution /results") !.WaitForExit();
        public void SolutionIsAnalyzedCorrectly(TestSolution testSolution)
        {
            var analysisRun = TestSolutionAnalyzer.Run(testSolution);

            Assert.Equal(analysisRun.Expected.Analysis.NormalizeJson(), analysisRun.Actual.Analysis.NormalizeJson());
        }
예제 #13
0
        public static TestSolutionAnalysisRun Run(TestSolution testSolution)
        {
            Program.Main(new[] { testSolution.Slug, testSolution.Directory });

            return(CreateTestSolutionAnalyisRun(testSolution));
        }