public void ShouldNot_DrawDot_When_LineIsCovered_But_TheCodeIsAfterDrawRange()
        {
            // arrange
            const string sourceCode = @"class Test
                                        {
                                            public void TestMethod()
                                            {
                                                int a=0;
                                            }
                                        }";

            _linesCoverage.Add(new LineCoverage());
            _linesCoverage[0].IsSuccess = true;
            _linesCoverage[0].NodePath = $"{ProjectName}.{DocumentName}.Test.TestMethod";
            _linesCoverage[0].Span = sourceCode.IndexOf("int a=0;", StringComparison.Ordinal);

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode, DocumentName);
            var lineStartPositions = GetLineStartPositions(sourceCode);

            // act
            CoverageDot[] dots = sut.Draw(lineStartPositions.Take(4).ToArray(), false, ProjectName).ToArray();

            // assert
            Assert.That(dots.Length, Is.EqualTo(0));
        }
        public void ShouldNot_DrawAnyDots_When_ThereAreNoMethodsInCode()
        {
            // arrange
            const string sourceCode = "using System;\nclass Test{\n}";

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode, DocumentName);

            // act
            IEnumerable<CoverageDot> dots = sut.Draw(GetLineStartPositions(sourceCode), true,ProjectName);

            // assert
            Assert.That(dots.Count(), Is.EqualTo(0));
        }
        public void Should_DrawSilveryDot_When_LineIsNotCovered_And_CalsAreNotInProgress()
        {
            // arrange
            const string sourceCode = @"class Test
                                        {
                                            public vodi TestMethod()
                                            {
                                                Assert.IsTrue(false);
                                            }
                                        }";

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode, DocumentName);

            // act
            CoverageDot[] dots = sut.Draw(GetLineStartPositions(sourceCode), false, ProjectName).ToArray();

            // assert
            Assert.That(dots.Length, Is.EqualTo(1));
            Assert.That(dots.First().Color, Is.EqualTo(Brushes.Silver));
        }
        public void Should_DrawRedDot_When_LineIsCovered_And_AssertionFailed()
        {
            // arrange
            const string sourceCode = @"class Test
                                        {
                                            public void TestMethod()
                                            {
                                                Assert.IsTrue(false);
                                            }
                                        }";

            _linesCoverage.Add(new LineCoverage());
            _linesCoverage[0].IsSuccess = false;
            _linesCoverage[0].NodePath = $"{ProjectName}.{DocumentName}.Test.TestMethod";
            _linesCoverage[0].Span = sourceCode.IndexOf("Assert.IsTrue(false)", StringComparison.Ordinal) -
                sourceCode.IndexOf("public void", StringComparison.Ordinal);

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode, DocumentName);

            // act
            CoverageDot[] dots = sut.Draw(GetLineStartPositions(sourceCode), false, ProjectName).ToArray();

            // assert
            Assert.That(dots.Length, Is.EqualTo(1));
            Assert.That(dots.First().Color, Is.EqualTo(Brushes.Red));
        }
        public void Should_DrawDot_BetweenLeadingTrivia_And_Statement()
        {
            // arrange
            const string sourceCode = @"class Test
                                        {
                                            public void TestMethod()
                                            {
                                                // leading trivia
                                                    int a=32;// line number 5
                                            }
                                        }";

            _linesCoverage.Add(new LineCoverage());
            _linesCoverage[0].IsSuccess = true;
            _linesCoverage[0].NodePath = $"{ProjectName}.{DocumentName}.Test.TestMethod";
            _linesCoverage[0].Span = sourceCode.IndexOf("int a=32", StringComparison.Ordinal)-
                      sourceCode.IndexOf("public void", StringComparison.Ordinal);

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode,DocumentName);

            // act
            CoverageDot[] dots = sut.Draw(GetLineStartPositions(sourceCode), false, ProjectName).ToArray();

            // assert
            Assert.That(dots.Length, Is.EqualTo(1));
            Assert.That(dots.First().LineNumber, Is.EqualTo(5));
            Assert.That(dots.First().Color, Is.EqualTo(Brushes.Green));
        }
        public void Should_DrawDots_ForAllMethods()
        {
            // arrange
            const string sourceCode = @"class Test
                                        {
                                            public void TestMethod()
                                            {
                                                int a=0;
                                            }

                                            public void TestMethod2()
                                            {
                                                int a=0;
                                                int b=0;
                                            }
                                        }";

            var sut = new CoverageDotDrawer(_linesCoverage, sourceCode, DocumentName);

            // act
            CoverageDot[] dots = sut.Draw(GetLineStartPositions(sourceCode), false, ProjectName).ToArray();

            // assert
            Assert.That(dots.Length, Is.EqualTo(3));
        }