Exemplo n.º 1
0
        public void VerifyFileNamesCountEndsInput()
        {
            var builder = new TestFunctionBuilder();

            Assert.False(builder.ParseInput("'D:\'.count().something", out var filesFunction, out var linesFunction));
            Assert.Contains("count()", builder.Error);
        }
Exemplo n.º 2
0
        public void VerifySyntaxError()
        {
            var builder = new TestFunctionBuilder();

            Assert.False(builder.ParseInput("'D:\'.apa()", out var filesFunction, out var linesFunction));
            Assert.Contains("apa()", builder.Error);
        }
Exemplo n.º 3
0
        public void VerifyLinesCount()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'C:'.containing('file2').lines().count()", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Single(result);
            Assert.Equal("3", result[0]);
        }
Exemplo n.º 4
0
        public void VerifyPresent()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'C:'.recursive().containing('file2').lines().containing('line3').present('{file}: {line}')", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(3, result.Count);
            Assert.Equal("file2: file2_line3", result[0]);
            Assert.Equal("dir1\\file2: dir1_file2_line3", result[1]);
            Assert.Equal("dir2\\file2: dir2_file2_line3", result[2]);
        }
Exemplo n.º 5
0
        public void VerifyAllLinesInOneFile()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'C:'.containing('file2').lines()", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(3, result.Count);
            Assert.Equal("file2_line1", result[0]);
            Assert.Equal("file2_line2", result[1]);
            Assert.Equal("file2_line3", result[2]);
        }
Exemplo n.º 6
0
        public void VerifyFileNames()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'D:\'", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(3, result.Count);
            Assert.Equal("file1", result[0]);
            Assert.Equal("file2", result[1]);
            Assert.Equal("file3", result[2]);
        }
Exemplo n.º 7
0
        public void VerifyFirstPartMustBeQuotedString()
        {
            var builder = new TestFunctionBuilder();

            Assert.False(builder.ParseInput("", out var filesFunction, out var linesFunction));
            Assert.Contains("first part must", builder.Error);

            Assert.False(builder.ParseInput("noquotes", out filesFunction, out linesFunction));
            Assert.Contains("first part must", builder.Error);

            Assert.True(builder.ParseInput("'quotes'", out filesFunction, out linesFunction));
            Assert.Equal("", builder.Error);
        }
Exemplo n.º 8
0
        public void VerifyFileNamesCount()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'D:\'.count()", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Single(result);
            Assert.Equal("3", result[0]);
            Assert.True(builder.ParseInput("'D:\'.recursive().count()", out filesFunction, out linesFunction));
            result = Runner.Run(filesFunction, linesFunction).ToList();
            Assert.Single(result);
            Assert.Equal("9", result[0]);
        }
Exemplo n.º 9
0
        public void VerifyFileNamesContainingRecursive()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'D:\'.recursive().containing('a')", out var filesFunction, out var linesFunction));
            Assert.Empty(filesFunction());

            Assert.True(builder.ParseInput("'D:\'.recursive().containing('file2')", out filesFunction, out linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(3, result.Count());
            Assert.Equal("file2", result[0]);
            Assert.Equal("dir1\\file2", result[1]);
            Assert.Equal("dir2\\file2", result[2]);
        }
Exemplo n.º 10
0
        public void VerifyAllLinesInCertainFiles()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'C:'.recursive().containing('file2').lines()", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(9, result.Count);
            Assert.Equal("file2_line1", result[0]);
            Assert.Equal("file2_line2", result[1]);
            Assert.Equal("file2_line3", result[2]);
            Assert.Equal("dir1_file2_line1", result[3]);
            Assert.Equal("dir1_file2_line2", result[4]);
            Assert.Equal("dir1_file2_line3", result[5]);
            Assert.Equal("dir2_file2_line1", result[6]);
            Assert.Equal("dir2_file2_line2", result[7]);
            Assert.Equal("dir2_file2_line3", result[8]);
        }
Exemplo n.º 11
0
        public void VerifyFileNamesRecursively()
        {
            var builder = new TestFunctionBuilder();

            Assert.True(builder.ParseInput("'D:\'.recursive()", out var filesFunction, out var linesFunction));
            var result = Runner.Run(filesFunction, linesFunction).ToList();

            Assert.Equal(9, result.Count);
            Assert.Equal("file1", result[0]);
            Assert.Equal("file2", result[1]);
            Assert.Equal("file3", result[2]);
            Assert.Equal("dir1\\file1", result[3]);
            Assert.Equal("dir1\\file2", result[4]);
            Assert.Equal("dir1\\file3", result[5]);
            Assert.Equal("dir2\\file1", result[6]);
            Assert.Equal("dir2\\file2", result[7]);
            Assert.Equal("dir2\\file3", result[8]);
        }