public void CountLinesTest(string content, int expected) { string path; IFileService fileService = TestFileServices.CreateSubstituteForFile(out path, content); fileService.CountLines(path).Should().Be(expected); }
public void BasicReadFileLinesTest() { string path; IFileService fileService = TestFileServices.CreateSubstituteForFile(out path, "a\nb\nc"); string[] lines = fileService.ReadLines(path).ToArray(); lines.Should().ContainInOrder("a", "b", "c"); }
public void FileArgument() { string path; IFileService fileService = TestFileServices.CreateSubstituteForFile(out path, "a\nb\nc\n@ @ @"); CommandLineParser parser = new CommandLineParser(fileService); parser.Parse(new string[] { "Command", @"/foo:@" + path }); parser.GetOption <string>("foo").Should().Be("a;b;c", "specified in file as a, b, c"); }
public void FileTarget() { string path; IFileService fileService = TestFileServices.CreateSubstituteForFile(out path, "a\nb\nc\n@ @ @"); CommandLineParser parser = new CommandLineParser(fileService); parser.Parse(new string[] { "Command", @"@" + path }); parser.Targets.Should().ContainInOrder("a", "b", "c"); }
public void ContainsStringTest(string content, string value, bool ignoreCase, bool expected) { string path; IFileService fileService = TestFileServices.CreateSubstituteForFile(out path, content); IEnumerable <string> containingPaths = fileService.ContainsString(value: value, ignoreCase: ignoreCase, paths: new string[] { path }); if (expected) { containingPaths.Should().Contain(path); } else { containingPaths.Should().NotContain(path); } }