public void Spec03() { using (var testable = new LintProjectItemsTestable()) { testable.GetMock <IJSLintContext>() .Setup(x => x.Lint(It.IsAny <string>(), It.IsAny <JSLintOptions>())) .Throws <Exception>(); var document = new Mock <Document>(); document .Setup(x => x.Object(It.IsAny <string>())) .Throws <Exception>(); for (int i = 1; i <= 51; i++) { var mockItem = testable.AddFile("file" + i + ".js", 0, true); mockItem .SetupGet(x => x.Document) .Returns(document.Object); } testable.Instance.LintProjectItems(testable.ProjectItems, testable.Settings); testable.Verify <IJSLintErrorListProvider>(x => x.AddCustomError(Resources.ExceptionLimitReachedFormat, 50)); Mock.Get(testable.ProjectItems[49]).Verify(x => x.Document); Mock.Get(testable.ProjectItems[50]).Verify(x => x.Document, Times.Never()); } }
public void Spec02() { using (var testable = new LintProjectItemsTestable()) { testable.Settings.FileLimit = 5; for (int i = 1; i <= 10; i++) { testable.AddFile("file" + i + ".js", 0); } testable.Instance.LintProjectItems(testable.ProjectItems, testable.Settings); testable.Verify <IJSLintErrorListProvider>(x => x.AddCustomError(Resources.FileLimitReachedFormat, 5)); testable.Verify <IJSLintContext>(x => x.Lint("file5.js contents", null, It.IsAny <IList <string> >())); testable.Verify <IJSLintContext>(x => x.Lint("file6.js contents", null, It.IsAny <IList <string> >()), Times.Never()); } }
public void Spec01() { using (var testable = new LintProjectItemsTestable()) { testable.Settings.ErrorLimit = 10; for (int i = 1; i <= 10; i++) { testable.AddFile("file" + i + ".js", 2); } testable.Instance.LintProjectItems(testable.ProjectItems, testable.Settings); testable.Verify <IJSLintErrorListProvider>(x => x.AddCustomError(Resources.ErrorLimitReachedFormat, 10)); testable.JSLintContextMock.Verify(x => x.Lint("file5.js contents", null)); testable.JSLintContextMock.Verify(x => x.Lint("file6.js contents", null), Times.Never()); } }