This repository was archived by the owner on Nov 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
268 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,52 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.30327.0 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.21916.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1477614-E825-4204-A684-385004B63AEB}" | ||
EndProject | ||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.FileSystems", "src\Microsoft.AspNet.FileSystems\Microsoft.AspNet.FileSystems.kproj", "{A830B046-595A-4992-B9E1-3C28C6440707}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E399495E-82B8-4C06-8779-C1D02BEF4495}" | ||
EndProject | ||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.FileSystems.Tests", "test\Microsoft.AspNet.FileSystems.Tests\Microsoft.AspNet.FileSystems.Tests.kproj", "{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|Mixed Platforms = Debug|Mixed Platforms | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|Mixed Platforms = Release|Mixed Platforms | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|x86.ActiveCfg = Debug|x86 | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|x86.Build.0 = Debug|x86 | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|x86.ActiveCfg = Release|x86 | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|x86.Build.0 = Release|x86 | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|Mixed Platforms.Build.0 = Release|Any CPU | ||
{A830B046-595A-4992-B9E1-3C28C6440707}.Release|x86.ActiveCfg = Release|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|x86.ActiveCfg = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{A830B046-595A-4992-B9E1-3C28C6440707} = {A1477614-E825-4204-A684-385004B63AEB} | ||
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9} = {E399495E-82B8-4C06-8779-C1D02BEF4495} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"sources": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
test/Microsoft.AspNet.FileSystems.Tests/EmbeddedResourceFileSystemTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNet.FileSystems | ||
{ | ||
public class EmbeddedResourceFileSystemTests | ||
{ | ||
[Fact] | ||
public void When_TryGetFileInfo_and_resource_does_not_exist_then_should_not_get_file_info() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, ""); | ||
|
||
IFileInfo fileInfo; | ||
provider.TryGetFileInfo("/DoesNotExist.Txt", out fileInfo).ShouldBe(false); | ||
|
||
fileInfo.ShouldBe(null); | ||
} | ||
|
||
[Fact] | ||
public void When_TryGetFileInfo_and_resource_exists_in_root_then_should_get_file_info() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, ""); | ||
|
||
IFileInfo fileInfo; | ||
provider.TryGetFileInfo("/File.txt", out fileInfo).ShouldBe(true); | ||
|
||
fileInfo.ShouldNotBe(null); | ||
fileInfo.LastModified.ShouldNotBe(default(DateTime)); | ||
fileInfo.Length.ShouldBeGreaterThan(0); | ||
fileInfo.IsDirectory.ShouldBe(false); | ||
fileInfo.PhysicalPath.ShouldBe(null); | ||
fileInfo.Name.ShouldBe("File.txt"); | ||
} | ||
|
||
[Fact] | ||
public void When_TryGetFileInfo_and_resource_exists_in_subdirectory_then_should_get_file_info() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Resources"); | ||
|
||
IFileInfo fileInfo; | ||
provider.TryGetFileInfo("/ResourcesInSubdirectory/File3.txt", out fileInfo).ShouldBe(true); | ||
|
||
fileInfo.ShouldNotBe(null); | ||
fileInfo.LastModified.ShouldNotBe(default(DateTime)); | ||
fileInfo.Length.ShouldBeGreaterThan(0); | ||
fileInfo.IsDirectory.ShouldBe(false); | ||
fileInfo.PhysicalPath.ShouldBe(null); | ||
fileInfo.Name.ShouldBe("ResourcesInSubdirectory/File3.txt"); | ||
} | ||
|
||
[Fact] | ||
public void When_TryGetFileInfo_and_resources_in_path_then_should_get_file_infos() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, ""); | ||
|
||
IFileInfo fileInfo; | ||
provider.TryGetFileInfo("/Resources/File.txt", out fileInfo).ShouldBe(true); | ||
|
||
fileInfo.ShouldNotBe(null); | ||
fileInfo.LastModified.ShouldNotBe(default(DateTime)); | ||
fileInfo.Length.ShouldBeGreaterThan(0); | ||
fileInfo.IsDirectory.ShouldBe(false); | ||
fileInfo.PhysicalPath.ShouldBe(null); | ||
fileInfo.Name.ShouldBe("Resources/File.txt"); | ||
} | ||
|
||
[Fact] | ||
public void TryGetDirInfo_with_slash() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Resources"); | ||
|
||
IEnumerable<IFileInfo> files; | ||
provider.TryGetDirectoryContents("/", out files).ShouldBe(true); | ||
files.Count().ShouldBe(2); | ||
|
||
provider.TryGetDirectoryContents("/file", out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("/file/", out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("/file.txt", out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("/file/txt", out files).ShouldBe(false); | ||
} | ||
|
||
[Fact] | ||
public void TryGetDirInfo_without_slash() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, ""); | ||
|
||
IEnumerable<IFileInfo> files; | ||
provider.TryGetDirectoryContents(string.Empty, out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("file", out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("file.txt", out files).ShouldBe(false); | ||
} | ||
|
||
[Fact] | ||
public void TryGetDirInfo_with_no_matching_base_namespace() | ||
{ | ||
var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Unknown.Namespace"); | ||
|
||
IEnumerable<IFileInfo> files; | ||
provider.TryGetDirectoryContents(string.Empty, out files).ShouldBe(false); | ||
provider.TryGetDirectoryContents("/", out files).ShouldBe(true); | ||
files.Count().ShouldBe(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello |
37 changes: 37 additions & 0 deletions
37
test/Microsoft.AspNet.FileSystems.Tests/Microsoft.AspNet.FileSystems.Tests.kproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>66fe5fdf-bbf9-4573-a7b7-53551731c0f9</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(OutputType) == 'Console'"> | ||
<DebuggerFlavor>ConsoleDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(OutputType) == 'Web'"> | ||
<DebuggerFlavor>WebDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration"> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration"> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="File.txt" /> | ||
<Content Include="Project.json" /> | ||
<Content Include="Resources\File.txt" /> | ||
<Content Include="Resources\ResourcesInSubdirectory\File3.txt" /> | ||
<Content Include="sub\File2.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="EmbeddedResourceFileSystemTests.cs" /> | ||
<Compile Include="PhysicalFileSystemTests.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
63 changes: 63 additions & 0 deletions
63
test/Microsoft.AspNet.FileSystems.Tests/PhysicalFileSystemTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.IO; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNet.FileSystems | ||
{ | ||
public class PhysicalFileSystemTests | ||
{ | ||
[Fact] | ||
public void ExistingFilesReturnTrue() | ||
{ | ||
var provider = new PhysicalFileSystem("."); | ||
IFileInfo info; | ||
provider.TryGetFileInfo("File.txt", out info).ShouldBe(true); | ||
info.ShouldNotBe(null); | ||
} | ||
|
||
[Fact] | ||
public void MissingFilesReturnFalse() | ||
{ | ||
var provider = new PhysicalFileSystem("."); | ||
IFileInfo info; | ||
provider.TryGetFileInfo("File5.txt", out info).ShouldBe(false); | ||
info.ShouldBe(null); | ||
} | ||
|
||
[Fact] | ||
public void SubPathActsAsRoot() | ||
{ | ||
var provider = new PhysicalFileSystem("sub"); | ||
IFileInfo info; | ||
provider.TryGetFileInfo("File2.txt", out info).ShouldBe(true); | ||
info.ShouldNotBe(null); | ||
} | ||
|
||
[Fact] | ||
public void RelativeOrAbsolutePastRootNotAllowed() | ||
{ | ||
var provider = new PhysicalFileSystem("sub"); | ||
IFileInfo info; | ||
|
||
provider.TryGetFileInfo("..\\File.txt", out info).ShouldBe(false); | ||
info.ShouldBe(null); | ||
|
||
provider.TryGetFileInfo(".\\..\\File.txt", out info).ShouldBe(false); | ||
info.ShouldBe(null); | ||
|
||
var applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; | ||
var file1 = Path.Combine(applicationBase, "File.txt"); | ||
var file2 = Path.Combine(applicationBase, "sub", "File2.txt"); | ||
provider.TryGetFileInfo(file1, out info).ShouldBe(false); | ||
info.ShouldBe(null); | ||
|
||
provider.TryGetFileInfo(file2, out info).ShouldBe(true); | ||
info.ShouldNotBe(null); | ||
info.PhysicalPath.ShouldBe(file2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"dependencies": { | ||
"Microsoft.AspNet.FileSystems": "", | ||
"Shouldly": "1.1.1.1", | ||
"Xunit.KRunner": "1.0.0-*" | ||
}, | ||
"commands": { | ||
"test": "Xunit.KRunner" | ||
}, | ||
"resources": "File.txt;sub/**;Resources/**", | ||
"frameworks": { | ||
"net45": { | ||
"dependencies": { | ||
"System.Runtime": "" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Resources-Hello |
1 change: 1 addition & 0 deletions
1
test/Microsoft.AspNet.FileSystems.Tests/Resources/ResourcesInSubdirectory/File3.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello2 |