Ejemplo n.º 1
0
        public void Should_add_violations_to_text_output()
        {
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(23, 44, "Something wrong", "evidence 1"));
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(33, 54, "Stupidity detected", "evidence 2"));

            var actual = this.Instance.ToString();

            Assert.Contains("Something wrong (line 23 character 44)", actual);
            Assert.Contains("Stupidity detected (line 33 character 54)", actual);
        }
Ejemplo n.º 2
0
        public void Should_not_add_files_without_violations_to_text_output()
        {
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(23, 44, "Something wrong", "evidence 1"));
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(33, 54, "Stupidity detected", "evidence 2"));
            this.Instance.AddFile("uberfile2.js");

            var actual = this.Instance.ToString();

            Assert.DoesNotContain("uberfile2.js", actual);
        }
Ejemplo n.º 3
0
        public void Should_add_files_with_count_to_text_output()
        {
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(23, 44, "Something wrong", "evidence 1"));
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(33, 54, "Stupidity detected", "evidence 2"));
            this.Instance.AddViolation("uberfile2.js", JSLintHelper.CreateJSLintError(33, 54, "Stupidity detected", "evidence 3"));

            var actual = this.Instance.ToString();

            Assert.Contains("uberfile.js (2 violations)", actual);
            Assert.Contains("uberfile2.js (1 violations)", actual);
        }
Ejemplo n.º 4
0
        public void Should_add_total_counts_to_text_output()
        {
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(23, 44, "Something wrong", null));
            this.Instance.AddFile("uberfile2.js");
            this.Instance.AddFile("uberfile3.js");

            var actual = this.Instance.ToString();

            Assert.Contains("3 processed files", actual);
            Assert.Contains("1 violating files", actual);
            Assert.Contains("1 total violations", actual);
        }
Ejemplo n.º 5
0
        public void Should_add_total_counts_to_HTML_output()
        {
            this.Instance.AddViolation("uberfile.js", JSLintHelper.CreateJSLintError(23, 44, "Something wrong", null));
            this.Instance.AddFile("uberfile2.js");
            this.Instance.AddFile("uberfile3.js");

            var actual = this.Instance.ToString();

            Expect.Matches(@"processed files[^\d]+3", RegexOptions.IgnoreCase, actual);
            Expect.Matches(@"violating files[^\d]+1", RegexOptions.IgnoreCase, actual);
            Expect.Matches(@"total violations[^\d]+1", RegexOptions.IgnoreCase, actual);
        }
Ejemplo n.º 6
0
            public void SetupJSLintFile(string fileName, int violationCount)
            {
                var contents   = fileName + " contents";
                var violations = new JSLintError[violationCount];

                for (int i = 0; i < violationCount; i++)
                {
                    var number = i + 1;
                    violations[i] = JSLintHelper.CreateJSLintError(number, number, fileName + " message " + number, fileName + " evidence " + number);
                }

                var list = new List <ITaskItem>(this.Instance.SourceFiles);

                list.Add(new TaskItem(fileName));
                this.Instance.SourceFiles = list.ToArray();

                this.FileSystemWrapperMock
                .Setup(x => x.ReadAllText(fileName, It.IsAny <Encoding>()))
                .Returns(contents);

                this.JSLinterMock
                .Setup(x => x.Lint(contents, It.IsAny <JSLintOptions>(), true))
                .Returns(new List <JSLintError>(violations));
            }