Exemplo n.º 1
0
        public void CreateGetSourceAndSequencePoints()
        {
            const uint   fileId1      = 1;
            const string sourceString = "abc { def }";

            var mockLog = new Mock <ILog>();
            var source  = new CodeCoverageStringTextSource(sourceString, "", mockLog.Object);

            var sRepo = new SourceRepository();

            sRepo[fileId1] = source;

            var spLeft = new SequencePoint()
            {
                FileId      = 1,
                StartLine   = 1,
                EndLine     = 1,
                StartColumn = 5,
                EndColumn   = 6
            };

            var spRight = new SequencePoint()
            {
                FileId      = 1,
                StartLine   = 1,
                EndLine     = 1,
                StartColumn = 11,
                EndColumn   = 12
            };

            var spInvalid = new SequencePoint()
            {
                FileId      = 2,
                StartLine   = 1,
                EndLine     = 1,
                StartColumn = 11,
                EndColumn   = 12
            };

            Assert.True(sRepo.GetCodeCoverageStringTextSource(0) == null);
            Assert.True(sRepo.GetCodeCoverageStringTextSource(1) == source);
            Assert.True(sRepo.GetCodeCoverageStringTextSource(2) == null);
            Assert.True(sRepo.GetCodeCoverageStringTextSource(1).GetLine(1) == sourceString);
            Assert.True(sRepo.GetCodeCoverageStringTextSource(1).GetText(spLeft) == "{");
            Assert.True(sRepo.GetCodeCoverageStringTextSource(1).GetText(spRight) == "}");

            Assert.True(sRepo.GetSequencePointText(null) == "");
            Assert.True(sRepo.GetSequencePointText(spInvalid) == "");

            Assert.True(sRepo.GetSequencePointText(spLeft) == "{");
            Assert.True(sRepo.GetSequencePointText(spRight) == "}");
        }