Esempio n. 1
0
        public void StrykerCLI_WithFilePatternSet_ShouldPassFilePatternSetToStryker(string argName)
        {
            var            mock          = new Mock <IStrykerRunner>(MockBehavior.Strict);
            StrykerOptions actualOptions = null;
            var            runResults    = new StrykerRunResult(new StrykerOptions(), 0.1);

            mock.Setup(x => x.RunMutationTest(It.IsAny <StrykerOptions>(), It.IsAny <IEnumerable <LogMessage> >()))
            .Callback <StrykerOptions, IEnumerable <LogMessage> >((c, m) => actualOptions = c)
            .Returns(runResults)
            .Verifiable();

            var target = new StrykerCLI(mock.Object);

            target.Run(new[] { argName, @"['**/*Service.cs','!**/MySpecialService.cs', '**/MyOtherService.cs{1..10}{32..45}']" });

            var firstFileToExclude  = FilePattern.Parse("**/*Service.cs");
            var secondFileToExclude = FilePattern.Parse("!**/MySpecialService.cs");
            var thirdFileToExclude  = FilePattern.Parse("**/MyOtherService.cs{1..10}{32..45}");

            var filePatterns = actualOptions.FilePatterns.ToArray();

            filePatterns.Length.ShouldBe(3);
            filePatterns.ShouldContain(firstFileToExclude);
            filePatterns.ShouldContain(secondFileToExclude);
            filePatterns.ShouldContain(thirdFileToExclude);
        }
Esempio n. 2
0
        public void StrykerCLI_WithFilesToExcludeSet_ShouldPassFilesToExcludeToStryker(string argName)
        {
            var            mock          = new Mock <IStrykerRunner>(MockBehavior.Strict);
            StrykerOptions actualOptions = null;
            var            runResults    = new StrykerRunResult(new StrykerOptions(), 0.1);

            mock.Setup(x => x.RunMutationTest(It.IsAny <StrykerOptions>(), It.IsAny <IEnumerable <LogMessage> >()))
            .Callback <StrykerOptions, IEnumerable <LogMessage> >((c, m) => actualOptions = c)
            .Returns(runResults)
            .Verifiable();

            var target = new StrykerCLI(mock.Object);

            target.Run(new[] { argName, @"['./StartUp.cs','./ExampleDirectory/Recursive.cs', './ExampleDirectory/Recursive2.cs']" });

            var firstFileToExclude  = FilePattern.Parse("!StartUp.cs");
            var secondFileToExclude = FilePattern.Parse("!ExampleDirectory/Recursive.cs");
            var thirdFileToExclude  = FilePattern.Parse("!ExampleDirectory/Recursive2.cs");

            var filePatterns = actualOptions.FilePatterns.ToArray();

            filePatterns.Count(x => x.IsExclude).ShouldBe(3);
            filePatterns.ShouldContain(firstFileToExclude);
            filePatterns.ShouldContain(secondFileToExclude);
            filePatterns.ShouldContain(thirdFileToExclude);
        }
Esempio n. 3
0
        [InlineData("{10..19}{20..30}", 15, 25, false)] // Two spans with gab; start and end of span are in the spans
        public void IsMatch_should_match_textSpans(string spanPattern, int spanStart, int spanEnd, bool isMatch)
        {
            // Arrange
            var sut = FilePattern.Parse("*.*" + spanPattern);

            // Act
            var result = sut.IsMatch($"test.cs", TextSpan.FromBounds(spanStart, spanEnd));

            // Assert
            result.ShouldBe(isMatch);
        }
Esempio n. 4
0
        public void Parse_should_parse_correctly(string spanPattern, string glob, bool isExclude, int[] spans)
        {
            // Arrange
            var textSpans = Enumerable.Range(0, spans.Length)
                            .GroupBy(i => Math.Floor(i / 2d))
                            .Select(x => TextSpan.FromBounds(spans[x.First()], spans[x.Skip(1).First()]));

            // Act
            var result = FilePattern.Parse(spanPattern);

            // Assert
            result.Glob.ToString().ShouldBe(FilePathUtils.NormalizePathSeparators(glob));
            result.IsExclude.ShouldBe(isExclude);
            result.TextSpans.SequenceEqual(textSpans).ShouldBe(true);
        }