示例#1
0
        public void should_return_empty_list_when_snippet_directory_does_not_exist()
        {
            // given
            var config = new JsonConfiguration();

            config.ScriptSnippetDirectory = "doesnt-exist";
            var snippetReader = new SnippetFileReader(config);

            // when
            IEnumerable <string> files = snippetReader.GetSnippetFilenames(ScriptSnippetType.BeforeExecute);

            // then
            Assert.That(files.Count(), Is.EqualTo(0));
        }
示例#2
0
        public void should_get_snippet_filenames_from_directory()
        {
            // given
            string typeDirectory = Path.Combine(_snippetDirectory, ScriptSnippetType.BeforeExecute.ToString().ToLower());

            string filename1 = Path.Combine(typeDirectory, "snippet1.snippet");
            string filename2 = Path.Combine(typeDirectory, "snippet2.snippet");

            File.WriteAllText(filename1, "snippet 1");
            File.WriteAllText(filename2, "snippet 2");

            var config = new JsonConfiguration();

            config.ScriptSnippetDirectory = _snippetDirectory;
            var snippetReader = new SnippetFileReader(config);

            // when
            IEnumerable <string> files = snippetReader.GetSnippetFilenames(ScriptSnippetType.BeforeExecute);

            // then
            Assert.That(files.Count(), Is.EqualTo(2));
            Assert.That(files, Contains.Item("snippet1.snippet"));
            Assert.That(files, Contains.Item("snippet2.snippet"));
        }
示例#3
0
        public void should_return_empty_list_when_snippet_sub_directory_does_not_exist()
        {
            // given
            string typeDirectory = Path.Combine(_snippetDirectory, ScriptSnippetType.BeforeExecute.ToString().ToLower());

            try
            {
                Directory.Delete(typeDirectory);
            }
            catch (IOException)
            {
            }

            var config = new JsonConfiguration();

            config.ScriptSnippetDirectory = _snippetDirectory;
            var snippetReader = new SnippetFileReader(config);

            // when
            IEnumerable <string> files = snippetReader.GetSnippetFilenames(ScriptSnippetType.BeforeExecute);

            // then
            Assert.That(files.Count(), Is.EqualTo(0));
        }
示例#4
0
 public IEnumerable <string> GetScriptSnippetFilenames(ScriptSnippetType snippetType)
 {
     return(_snippetFileReader.GetSnippetFilenames(snippetType));
 }