You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
eglib
external
Lucene.Net.Light
Newtonsoft.Json
android-libunwind
aspnetwebstack
packages
src
test
Microsoft.TestCommon
Microsoft
Properties
AppDomainUtils.cs
AssertEx.cs
CultureReplacer.cs
DefaultTimeoutFactAttribute.cs
DefaultTimeoutTheoryAttribute.cs
DictionaryEqualityComparer.cs
ExceptionAssertions.cs
ForceGCAttribute.cs
MemberHelper.cs
Microsoft.TestCommon.csproj
PartialTrustRunner.cs
PreAppStartTestHelper.cs
PreserveSyncContextAttribute.cs
ReflectionAssert.cs
RestoreThreadPrincipalAttribute.cs
TaskExtensions.cs
TestFile.cs
TestHelper.cs
TheoryDataSet.cs
ThreadPoolSyncContext.cs
WebUtils.cs
packages.config
Microsoft.Web.Helpers.Test
Microsoft.Web.Http.Data.Test
Microsoft.Web.Mvc.Test
Microsoft.Web.WebPages.OAuth.Test
SPA.Test
System.Json.Test.Integration
System.Json.Test.Unit
System.Net.Http.Formatting.Test.Integration
System.Net.Http.Formatting.Test.Unit
System.Web.Helpers.Test
System.Web.Http.Integration.Test
System.Web.Http.SelfHost.Test
System.Web.Http.Test
System.Web.Http.WebHost.Test
System.Web.Mvc.Test
System.Web.Razor.Test
System.Web.WebPages.Administration.Test
System.Web.WebPages.Deployment.Test
System.Web.WebPages.Razor.Test
System.Web.WebPages.Test
WebMatrix.Data.Test
WebMatrix.WebData.Test
Settings.StyleCop
tools
.gitattributes
.gitignore
License.txt
README.md
Runtime.msbuild
Runtime.sln
Runtime.xunit
Settings.StyleCop
build.cmd
binary-reference-assemblies
boringssl
buildtools
cecil
cecil-legacy
debian-snapshot
ikdasm
ikvm
nuget-buildtasks
nunit-lite
rx
ikvm-native
libgc
llvm
m4
man
mcs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using Xunit;
|
|
|
|
namespace System.Web.WebPages.TestUtils
|
|
{
|
|
public class TestFile
|
|
{
|
|
public const string ResourceNameFormat = "{0}.TestFiles.{1}";
|
|
|
|
public string ResourceName { get; set; }
|
|
public Assembly Assembly { get; set; }
|
|
|
|
public TestFile(string resName, Assembly asm)
|
|
{
|
|
ResourceName = resName;
|
|
Assembly = asm;
|
|
}
|
|
|
|
public static TestFile Create(string localResourceName)
|
|
{
|
|
return new TestFile(String.Format(ResourceNameFormat, Assembly.GetCallingAssembly().GetName().Name, localResourceName), Assembly.GetCallingAssembly());
|
|
}
|
|
|
|
public Stream OpenRead()
|
|
{
|
|
Stream strm = Assembly.GetManifestResourceStream(ResourceName);
|
|
if (strm == null)
|
|
{
|
|
Assert.True(false, String.Format("Manifest resource: {0} not found", ResourceName));
|
|
}
|
|
return strm;
|
|
}
|
|
|
|
public byte[] ReadAllBytes()
|
|
{
|
|
using (Stream stream = OpenRead())
|
|
{
|
|
byte[] buffer = new byte[stream.Length];
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
return buffer;
|
|
}
|
|
}
|
|
|
|
public string ReadAllText()
|
|
{
|
|
using (StreamReader reader = new StreamReader(OpenRead()))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Saves the file to the specified path.
|
|
/// </summary>
|
|
public void Save(string filePath)
|
|
{
|
|
var directory = Path.GetDirectoryName(filePath);
|
|
if (!Directory.Exists(directory))
|
|
{
|
|
Directory.CreateDirectory(directory);
|
|
}
|
|
|
|
using (Stream outStream = File.Create(filePath))
|
|
{
|
|
using (Stream inStream = OpenRead())
|
|
{
|
|
inStream.CopyTo(outStream);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|