Exemplo n.º 1
0
        public void GetDirectoryContents_PartialMatchFails(string requestedUrl)
        {
            // Arrange
            var provider = new StaticWebAssetsFileProvider("/_content/RazorClassLib", AppContext.BaseDirectory);

            // Act
            var directory = provider.GetDirectoryContents(requestedUrl);

            // Assert
            Assert.Empty(directory);
        }
Exemplo n.º 2
0
        public void GetDirectoryContents_DoesNotFindNonExistentFiles()
        {
            // Arrange
            var provider = new StaticWebAssetsFileProvider("/_content/RazorClassLib/", AppContext.BaseDirectory);

            // Act
            var directory = provider.GetDirectoryContents("/_content/RazorClassLib/False");

            // Assert
            Assert.Empty(directory);
        }
Exemplo n.º 3
0
        public void GetDirectoryContents_WalksUpContentRoot(string searchDir, string expected)
        {
            // Arrange
            var provider = new StaticWebAssetsFileProvider("/_content/RazorClassLib/Dir", AppContext.BaseDirectory);

            // Act
            var directory = provider.GetDirectoryContents(searchDir);

            // Assert
            Assert.NotEmpty(directory);
            Assert.Contains(directory, file => string.Equals(file.Name, expected));
        }
Exemplo n.º 4
0
        public void GetDirectoryContents_HandlersEmptyPath()
        {
            // Arrange
            var provider = new StaticWebAssetsFileProvider("/_content",
                                                           Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));

            // Act
            var directory = provider.GetDirectoryContents("");

            // Assert
            Assert.True(directory.Exists);
        }
Exemplo n.º 5
0
        public void GetDirectoryContents_Prefix_RespectsOsCaseSensitivity()
        {
            // Arrange
            var expectedResult = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            var provider       = new StaticWebAssetsFileProvider(
                "_content",
                Path.GetDirectoryName(new Uri(typeof(StaticWebAssetsFileProviderTests).Assembly.CodeBase).LocalPath));

            // Act
            var directory = provider.GetDirectoryContents("/_CONTENT");

            // Assert
            Assert.Equal(expectedResult, directory.Exists);
        }
Exemplo n.º 6
0
        public void GetDirectoryContents_Prefix_RespectsOsCaseSensitivity()
        {
            // Arrange
            var expectedResult = OperatingSystem.IsWindows();
            var provider       = new StaticWebAssetsFileProvider(
                "_content",
                Path.GetDirectoryName(typeof(StaticWebAssetsFileProviderTests).Assembly.Location));

            // Act
            var directory = provider.GetDirectoryContents("/_CONTENT");

            // Assert
            Assert.Equal(expectedResult, directory.Exists);
        }
Exemplo n.º 7
0
        public void GetDirectoryContents_HandlesWhitespaceInBase()
        {
            // Arrange
            var provider = new StaticWebAssetsFileProvider("/_content/Static Web Assets",
                                                           Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));

            // Act
            var directory = provider.GetDirectoryContents("/_content/Static Web Assets/Static Web/");

            // Assert
            Assert.Collection(directory,
                              file =>
            {
                Assert.Equal("Static Web.txt", file.Name);
            });
        }