Ejemplo n.º 1
0
        private bool FilesAreEquivalent(AnalyzerLanguage language, out List <string> problematicRules)
        {
            problematicRules = new List <string>();

            var expectedFiles = ExpectedDirectory
                                .GetDirectories(language.GetDirectoryName()).First()
                                .GetFiles("S*.json");
            var actualFiles = AnalysisOutputDirectory
                              .GetDirectories(language.GetDirectoryName()).First()
                              .GetFiles("S*.json");

            var problematicFileNames =
                expectedFiles.Select(file => file.Name)
                .ToImmutableHashSet()
                .SymmetricExcept(actualFiles.Select(file => file.Name));

            if (problematicFileNames.Any())
            {
                problematicRules.AddRange(problematicFileNames);
                return(false);
            }

            foreach (var expectedFile in expectedFiles)
            {
                var bytesExpected = File.ReadAllBytes(expectedFile.FullName);
                var bytesActual   = File.ReadAllBytes(actualFiles.Single(file => file.Name == expectedFile.Name).FullName);

                if (!StructuralComparisons.StructuralEqualityComparer.Equals(bytesExpected, bytesActual))
                {
                    problematicRules.Add(Path.GetFileNameWithoutExtension(expectedFile.Name));
                }
            }

            return(!problematicRules.Any());
        }
Ejemplo n.º 2
0
 private void CreateMissingExpectedDirectory(AnalyzerLanguage language)
 {
     if (!ExpectedDirectory.GetDirectories(language.GetDirectoryName()).Any())
     {
         Directory.CreateDirectory(Path.Combine(
                                       ExpectedDirectory.FullName,
                                       language.GetDirectoryName()));
     }
 }
Ejemplo n.º 3
0
        private void CheckIntegrationTestCount(AnalyzerLanguage language)
        {
            ValidateLanguageInput(language);
            CreateMissingExpectedDirectory(language);

            Assert.AreEqual(
                RuleFinder.GetAnalyzerTypes(language).Count(),
                ExpectedDirectory
                .GetDirectories(language.GetDirectoryName()).First()
                .GetFiles("S*.json").Count());
        }