Exemplo n.º 1
0
        public void FilesLocator_Throws_When_No_Matches_In_SearchPaths()
        {
            MockFileSystem fs = new MockFileSystem();
            var folders = new[] { @"C:\One", @"C:\Two" };
            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\template1.cshtml", "");
            fs.WriteAllText(@"C:\Two\template2.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", folders));
            Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message);
        }
Exemplo n.º 2
0
        public void FilesLocator_Throws_When_Multiple_Matches_In_OneSearchPath()
        {
            MockFileSystem fs = new MockFileSystem();
            var folders = new[] { @"C:\One", @"C:\One\Sub1", @"C:\One\Sub2" };
            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\Sub1\template.cshtml", "");
            fs.WriteAllText(@"C:\One\Sub2\template.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One" }));
            Assert.Equal(@"Multiple files with name template.cshtml found within C:\One", ex.Message);
        }
Exemplo n.º 3
0
        public void FilesLocator_Returns_Entry_From_FirstSearchPath()
        {
            MockFileSystem fs = new MockFileSystem();
            var folders = new[] { @"C:\One", @"C:\Two" };
            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\template.cshtml", "");
            fs.WriteAllText(@"C:\Two\template.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var result = locator.GetFilePath("template.cshtml", folders);

            Assert.Equal(@"C:\One\template.cshtml", result);
        }
Exemplo n.º 4
0
        public void FilesLocator_Throws_When_No_Matches_In_SearchPaths()
        {
            MockFileSystem fs      = new MockFileSystem();
            var            folders = new[] { @"C:\One", @"C:\Two" };

            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\template1.cshtml", "");
            fs.WriteAllText(@"C:\Two\template2.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var ex = Assert.Throws <InvalidOperationException>(() => locator.GetFilePath("template.cshtml", folders));

            Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message);
        }
Exemplo n.º 5
0
        public void FilesLocator_Throws_When_Multiple_Matches_In_OneSearchPath()
        {
            MockFileSystem fs      = new MockFileSystem();
            var            folders = new[] { @"C:\One", @"C:\One\Sub1", @"C:\One\Sub2" };

            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\Sub1\template.cshtml", "");
            fs.WriteAllText(@"C:\One\Sub2\template.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var ex = Assert.Throws <InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One" }));

            Assert.Equal(@"Multiple files with name template.cshtml found within C:\One", ex.Message);
        }
Exemplo n.º 6
0
        public void FilesLocator_Returns_Entry_From_FirstSearchPath()
        {
            MockFileSystem fs      = new MockFileSystem();
            var            folders = new[] { @"C:\One", @"C:\Two" };

            fs.AddFolders(folders);

            fs.WriteAllText(@"C:\One\template.cshtml", "");
            fs.WriteAllText(@"C:\Two\template.cshtml", "");
            FilesLocator locator = new FilesLocator(fs);

            var result = locator.GetFilePath("template.cshtml", folders);

            Assert.Equal(@"C:\One\template.cshtml", result);
        }