Esempio n. 1
0
            public void Spec14()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 3);
                    testable.SetupJSLintFile("file2.js", 5);

                    testable.Instance.Execute();

                    testable.JSLintReportBuilderMock.Verify(x => x.AddFile(It.Is <string>(y => y.EndsWith("file1.js")), It.IsAny <IJSLintData>()));
                    testable.JSLintReportBuilderMock.Verify(x => x.AddFile(It.Is <string>(y => y.EndsWith("file2.js")), It.IsAny <IJSLintData>()));
                }
            }
Esempio n. 2
0
            public void Spec15()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file.js", 0);

                    testable.Instance.ReportFile = "REPORTFILE";
                    testable.Instance.Execute();

                    testable.JSLintReportBuilderMock.Verify(x => x.ToString());
                    testable.Verify <IFileSystemWrapper>(x => x.WriteAllText(@"D:\solution\source\project\REPORTFILE", "REPORTRESULT", Encoding.UTF8));
                }
            }
Esempio n. 3
0
            public void Spec10()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 2);
                    testable.SetupJSLintFile("file2.js", 0);
                    testable.SetupJSLintFile("file3.js", 3);

                    testable.Instance.Execute();

                    I.Expect(testable.Instance.ErrorFileCount).ToBe(2);
                }
            }
Esempio n. 4
0
            public void Spec19()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.Settings.ErrorLimit = 10;
                    testable.SettingsExist       = true;
                    testable.SetupJSLintFile("file.js", 11);

                    testable.Instance.Execute();

                    I.Expect(testable.BuildEngine.ErrorEvents).ToContain(x => x.Message == string.Format(Resources.ErrorLimitReachedFormat, 11));
                }
            }
Esempio n. 5
0
            public void Spec06()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 0);
                    testable.SetupJSLintFile("jsfile2.js", 0);

                    testable.Instance.Execute();

                    testable.JSLintContextMock.Verify(x => x.Lint("file1.js contents", It.IsAny <JSLintOptions>()));
                    testable.JSLintContextMock.Verify(x => x.Lint("jsfile2.js contents", It.IsAny <JSLintOptions>()));
                    testable.JSLintContextMock.Verify(x => x.Lint(It.IsAny <string>(), It.IsAny <JSLintOptions>()), Times.Exactly(2));
                }
            }
Esempio n. 6
0
            public void Spec11()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 3);
                    testable.SetupJSLintFile("file2.js", 0);
                    testable.SetupJSLintFile("file3.js", 0);
                    testable.SetupJSLintFile("file4.js", 1);

                    testable.Instance.Execute();

                    I.Expect(testable.Instance.ProcessedFileCount).ToBe(4);
                }
            }
Esempio n. 7
0
            public void Spec09()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 2);
                    testable.SetupJSLintFile("file2.js", 1);
                    testable.SetupJSLintFile("file3.js", 5);
                    testable.SetupJSLintFile("file4.js", 2);

                    testable.Instance.Execute();

                    I.Expect(testable.Instance.ErrorCount).ToBe(10);
                }
            }
Esempio n. 8
0
            public void Spec18()
            {
                using (var testable = new ExecuteTestable())
                {
                    for (int i = 0; i < JSLintNetSettings.DefaultFileLimit; i++)
                    {
                        testable.SetupJSLintFile("file" + i + ".js", 0);
                    }

                    testable.Instance.Execute();

                    I.Expect(testable.BuildEngine.ErrorEvents).ToContain(x => x.Message == string.Format(Resources.FileLimitReachedFormat, JSLintNetSettings.DefaultFileLimit));
                }
            }
Esempio n. 9
0
            public void Spec20()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.Settings.FileLimit = 10;
                    testable.SettingsExist      = true;

                    testable.SetupJSLintFile("file.js", 0);
                    testable.ProcessedFileCount = 11;

                    testable.Instance.Execute();

                    testable.LoggingHelperMock.Verify(x => x.LogError(Resources.FileLimitReachedFormat, 11));
                }
            }
Esempio n. 10
0
            public void Spec07()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.SetupJSLintFile("file1.js", 2);
                    testable.SetupJSLintFile("jsfile2.js", 1);

                    testable.Instance.Execute();

                    testable.LoggingHelperMock.Verify(x => x.LogError(It.IsAny <string>(), null, null, It.Is <string>(y => y.EndsWith("file1.js")), 1, 1, 0, 0, "JSLint : file1.js message 1"));
                    testable.LoggingHelperMock.Verify(x => x.LogError(It.IsAny <string>(), null, null, It.Is <string>(y => y.EndsWith("file1.js")), 2, 2, 0, 0, "JSLint : file1.js message 2"));
                    testable.LoggingHelperMock.Verify(x => x.LogError(It.IsAny <string>(), null, null, It.Is <string>(y => y.EndsWith("jsfile2.js")), 1, 1, 0, 0, "JSLint : jsfile2.js message 1"));
                    testable.LoggingHelperMock.Verify(x => x.LogWarning(It.IsAny <string>(), null, null, It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), 0, 0, It.IsAny <string>()), Times.Never());
                }
            }
Esempio n. 11
0
            public void Spec20()
            {
                using (var testable = new ExecuteTestable())
                {
                    testable.Settings.FileLimit = 10;
                    testable.SettingsExist      = true;

                    for (int i = 0; i < 10; i++)
                    {
                        testable.SetupJSLintFile("file" + i + ".js", 0);
                    }

                    testable.Instance.Execute();

                    I.Expect(testable.BuildEngine.ErrorEvents).ToContain(x => x.Message == string.Format(Resources.FileLimitReachedFormat, 10));
                }
            }
Esempio n. 12
0
            public void Spec17()
            {
                using (var testable = new ExecuteTestable())
                {
                    for (int i = 0; i < JSLintNetSettings.ExceptionLimit; i++)
                    {
                        var filePath = Path.Combine(testable.SourceDirectory, "file" + i + ".js");
                        testable.SourceFiles.Add(filePath);
                    }

                    testable.JSLintContextMock
                    .Setup(x => x.Lint(It.IsAny <string>(), It.IsAny <JSLintOptions>()))
                    .Throws <Exception>();

                    testable.Instance.Execute();

                    testable.LoggingHelperMock.Verify(x => x.LogError(Resources.ExceptionLimitReachedFormat, JSLintNetSettings.ExceptionLimit));
                }
            }
Esempio n. 13
0
            public void Spec17()
            {
                using (var testable = new ExecuteTestable())
                {
                    for (int i = 0; i < JSLintNetSettings.ExceptionLimit; i++)
                    {
                        var filePath = Path.Combine(testable.SourceDirectory, "file" + i + ".js");
                        testable.SourceFiles.Add(filePath);
                    }

                    testable.GetMock <IJSLintContext>()
                    .Setup(x => x.Lint(It.IsAny <string>(), It.IsAny <JSLintOptions>(), It.IsAny <IList <string> >()))
                    .Throws <Exception>();

                    testable.Instance.Execute();

                    I.Expect(testable.BuildEngine.ErrorEvents).ToContain(x => x.Message == string.Format(Resources.ExceptionLimitReachedFormat, JSLintNetSettings.ExceptionLimit));
                }
            }
Esempio n. 14
0
                public void SetupJSLintFile(string fileName, int errorCount = 0)
                {
                    using (var testable = new ExecuteTestable())
                    {
                        var filePath = Path.Combine(this.SourceDirectory, fileName);
                        this.SourceFiles.Add(filePath);

                        var contents = fileName + " contents";
                        var data     = new JSLintDataFake(fileName, errorCount);

                        this.GetMock <IFileSystemWrapper>()
                        .Setup(x => x.ReadAllText(filePath, It.IsAny <Encoding>()))
                        .Returns(contents);

                        this.GetMock <IJSLintContext>()
                        .Setup(x => x.Lint(contents, It.IsAny <JSLintOptions>(), It.IsAny <IList <string> >()))
                        .Returns(data);
                    }
                }