public void CheckForSpecialRepetition()
        {
            var csUris = dir.GetFilesInDirectory(dir.ModifiedTestDirPath, FileTypes.cs);

            var csUrisWithoutUnitTests = csUris.Where(a => !a.Contains("UnitConverterTests")).ToList();

            var htmlUris = dir.GetFilesInDirectory(dir.ModifiedTestDirPath, FileTypes.html).ToList();

            var combinedList = csUrisWithoutUnitTests.Concat(htmlUris);

            var stringRep      = 0;
            var yardRepetition = 0;
            var inchRepetition = 0;
            var mileRepetition = 0;

            const string regexPatternForInts = "[0-9]+\\.?[0-9]*";

            foreach (var csFile in combinedList)
            {
                var file = File.ReadAllText(csFile);

                yardRepetition += CountRepetition(yardsToMeters, file, regexPatternForInts);
                inchRepetition += CountRepetition(inchToCentimeter, file, regexPatternForInts);
                mileRepetition += CountRepetition(mileToKilometer, file, regexPatternForInts);

                stringRep += CountRepetition(stringCheck, file, stringCheck);
            }

            if (yardRepetition > VARIABLE_REPETITION_TRESHOLD)
            {
                resultsOutput.AppendLine($"Number {yardsToMeters} duplicated {yardRepetition} times");
            }
            if (inchRepetition > VARIABLE_REPETITION_TRESHOLD)
            {
                resultsOutput.AppendLine($"Number {inchToCentimeter} duplicated {inchRepetition} times");
            }
            if (mileRepetition > VARIABLE_REPETITION_TRESHOLD)
            {
                resultsOutput.AppendLine($"Number {mileToKilometer} duplicated {mileRepetition} times");
            }
            if (stringRep > VARIABLE_REPETITION_TRESHOLD)
            {
                resultsOutput.AppendLine($"String \"Yards to meters\" duplicated {stringRep} times");
            }
        }
Example #2
0
        private List <string[]> GetFileText()
        {
            var csUris = pathManager.GetFilesInDirectory(pathManager.ModifiedTestDirPath, FileTypes.cs);

            List <string[]> fileText = new List <string[]>();

            csUris.Where(a => a.Contains("UnitConverterTests")).ToList().ForEach(i => fileText.Add(File.ReadAllLines(i)));

            return(fileText);
        }
Example #3
0
        public Task <List <FeatureEvidence> > Execute()
        {
            return(Task.Run(() =>
            {
                var files = pathManager.GetFilesInDirectory(pathManager.ModifiedTestDirPath, FileTypes.sln, SearchOption.TopDirectoryOnly);

                if (files.Any())
                {
                    SolutionFileEvidence.SetPassed(new SimpleEvidenceBuilder("Solution file found"));
                }
                else
                {
                    SolutionFileEvidence.SetFailed(new SimpleEvidenceBuilder("Solution file not found"));
                }
                return new List <FeatureEvidence> {
                    SolutionFileEvidence
                };
            }));
        }