예제 #1
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.JSLintContextMock
                        .Setup(x => x.Lint(contents, It.IsAny <JSLintOptions>()))
                        .Returns(data);

                        this.ProcessedFileCount += 1;

                        if (errorCount > 0)
                        {
                            this.ErrorFileCount += 1;
                            this.ErrorCount     += errorCount;
                        }
                    }
                }
                public JSLintDataFake SetupFile(string fileName, int errorCount)
                {
                    var filePath = Path.Combine(this.Options.SourceDirectory, fileName);
                    var fake     = new JSLintDataFake(fileName, errorCount);
                    var source   = fileName + " contents";

                    this.GetMock <IFileSystemWrapper>()
                    .Setup(x => x.ReadAllText(filePath, Encoding.UTF8))
                    .Returns(source);

                    this.JSLintContextMock
                    .Setup(x => x.Lint(source, null))
                    .Returns(fake);

                    this.Options.SourceFiles.Add(filePath);

                    return(fake);
                }