You've already forked linux-packaging-mono
Imported Upstream version 5.20.0.180
Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
parent
0e2d47d1c8
commit
0510252385
@@ -12,6 +12,8 @@ using System.IO;
|
||||
using System.Resources;
|
||||
using NUnit.Framework;
|
||||
|
||||
using MonoTests.Helpers;
|
||||
|
||||
namespace MonoTests.System.Resources
|
||||
{
|
||||
[TestFixture]
|
||||
@@ -47,21 +49,13 @@ namespace MonoTests.System.Resources
|
||||
[Test]
|
||||
public void TestReader ()
|
||||
{
|
||||
string fileName = Path.Combine (Path.Combine ("Test", "System.Resources"), "compat_1_1.resx");
|
||||
if (!File.Exists (fileName))
|
||||
fileName = String.Format ("..{0}System.Resources{0}compat_1_1.resx", Path.DirectorySeparatorChar);
|
||||
|
||||
Helper.TestReader (fileName);
|
||||
Helper.TestReader (TestResourceHelper.GetFullPathOfResource ("Test/System.Resources/compat_1_1.resx"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReader_2_0 ()
|
||||
{
|
||||
string fileName = Path.Combine (Path.Combine ("Test", "System.Resources"), "compat_2_0.resx");
|
||||
if (!File.Exists (fileName))
|
||||
fileName = String.Format ("..{0}System.Resources{0}compat_2_0.resx", Path.DirectorySeparatorChar);
|
||||
|
||||
Helper.TestReader (fileName);
|
||||
Helper.TestReader (TestResourceHelper.GetFullPathOfResource ("Test/System.Resources/compat_2_0.resx"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ using System.Runtime.Serialization;
|
||||
using NUnit.Framework;
|
||||
using System.Reflection;
|
||||
|
||||
using MonoTests.Helpers;
|
||||
|
||||
namespace MonoTests.System.Resources {
|
||||
[TestFixture]
|
||||
public class ResXResourceReaderTest : MonoTests.System.Windows.Forms.TestHelper
|
||||
@@ -116,9 +118,7 @@ namespace MonoTests.System.Resources {
|
||||
[Test]
|
||||
public void Close_FileName ()
|
||||
{
|
||||
string fileName = Path.Combine (Path.Combine ("Test", "System.Resources"), "compat_1_1.resx");
|
||||
if (!File.Exists (fileName))
|
||||
fileName = String.Format ("..{0}System.Resources{0}compat_1_1.resx", Path.DirectorySeparatorChar);
|
||||
string fileName = TestResourceHelper.GetFullPathOfResource ("Test/System.Resources/compat_1_1.resx");
|
||||
|
||||
ResXResourceReader r1 = new ResXResourceReader (fileName);
|
||||
r1.GetEnumerator ();
|
||||
@@ -134,9 +134,7 @@ namespace MonoTests.System.Resources {
|
||||
[Test]
|
||||
public void Close_Reader ()
|
||||
{
|
||||
string fileName = Path.Combine (Path.Combine ("Test", "System.Resources"), "compat_1_1.resx");
|
||||
if (!File.Exists (fileName))
|
||||
fileName = String.Format ("..{0}System.Resources{0}compat_1_1.resx", Path.DirectorySeparatorChar);
|
||||
string fileName = TestResourceHelper.GetFullPathOfResource ("Test/System.Resources/compat_1_1.resx");
|
||||
|
||||
using (StreamReader sr = new StreamReader (fileName)) {
|
||||
ResXResourceReader r = new ResXResourceReader (sr);
|
||||
@@ -172,9 +170,7 @@ namespace MonoTests.System.Resources {
|
||||
[Test]
|
||||
public void Close_Stream ()
|
||||
{
|
||||
string fileName = Path.Combine (Path.Combine ("Test", "System.Resources"), "compat_1_1.resx");
|
||||
if (!File.Exists (fileName))
|
||||
fileName = String.Format ("..{0}System.Resources{0}compat_1_1.resx", Path.DirectorySeparatorChar);
|
||||
string fileName = TestResourceHelper.GetFullPathOfResource ("Test/System.Resources/compat_1_1.resx");
|
||||
|
||||
using (FileStream fs = File.OpenRead (fileName)) {
|
||||
ResXResourceReader r = new ResXResourceReader (fs);
|
||||
@@ -200,7 +196,7 @@ namespace MonoTests.System.Resources {
|
||||
public void ExternalFileReference_Icon ()
|
||||
{
|
||||
string refFile = Path.Combine (_tempDirectory, "32x32.ico");
|
||||
WriteEmbeddedResource ("32x32.ico", refFile);
|
||||
File.Copy (TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico"), refFile);
|
||||
|
||||
string resxFile = Path.Combine (_tempDirectory, "resources.resx");
|
||||
using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
|
||||
@@ -226,7 +222,7 @@ namespace MonoTests.System.Resources {
|
||||
File.Delete (resxFile);
|
||||
|
||||
refFile = Path.Combine (_tempDirectory, "32x32.ICO");
|
||||
WriteEmbeddedResource ("32x32.ico", refFile);
|
||||
File.Copy (TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico"), refFile);
|
||||
|
||||
using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
|
||||
sw.Write (string.Format (CultureInfo.InvariantCulture,
|
||||
@@ -1473,8 +1469,7 @@ namespace MonoTests.System.Resources {
|
||||
[Test]
|
||||
public void UseResXDataNodes ()
|
||||
{
|
||||
string refFile = Path.Combine (_tempDirectory, "32x32.ico");
|
||||
WriteEmbeddedResource ("32x32.ico", refFile);
|
||||
string refFile = TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico");
|
||||
|
||||
string resxFile = Path.Combine (_tempDirectory, "resources.resx");
|
||||
using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
|
||||
@@ -1520,8 +1515,7 @@ namespace MonoTests.System.Resources {
|
||||
{
|
||||
// This test relies on a hashtable's enumerator being ordered,
|
||||
// when the ordering is not guaranteed.
|
||||
string refFile = Path.Combine (_tempDirectory, "32x32.ico");
|
||||
WriteEmbeddedResource ("32x32.ico", refFile);
|
||||
string refFile = TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico");
|
||||
|
||||
string resxFile = Path.Combine (_tempDirectory, "resources.resx");
|
||||
using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
|
||||
@@ -1545,8 +1539,7 @@ namespace MonoTests.System.Resources {
|
||||
[Test]
|
||||
public void GetMetadataEnumerator ()
|
||||
{
|
||||
string refFile = Path.Combine (_tempDirectory, "32x32.ico");
|
||||
WriteEmbeddedResource ("32x32.ico", refFile);
|
||||
string refFile = TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico");
|
||||
|
||||
string resxFile = Path.Combine (_tempDirectory, "resources.resx");
|
||||
using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
|
||||
|
@@ -38,9 +38,10 @@ using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using MonoTests.Helpers;
|
||||
|
||||
namespace MonoTests.System.Resources {
|
||||
public class ResourcesTestHelper {
|
||||
string tempFileWithIcon = null;
|
||||
string tempFileWithSerializable = null;
|
||||
|
||||
[SetUp]
|
||||
@@ -82,45 +83,19 @@ namespace MonoTests.System.Resources {
|
||||
|
||||
public ResXDataNode GetNodeEmdeddedIcon ()
|
||||
{
|
||||
Stream input = typeof (ResXDataNodeTest).Assembly.
|
||||
GetManifestResourceStream ("32x32.ico");
|
||||
|
||||
Icon ico = new Icon (input);
|
||||
Icon ico = new Icon (TestResourceHelper.GetStreamOfResource ("Test/resources/32x32.ico"));
|
||||
ResXDataNode node = new ResXDataNode ("test", ico);
|
||||
return node;
|
||||
}
|
||||
|
||||
public ResXDataNode GetNodeFileRefToIcon ()
|
||||
{
|
||||
tempFileWithIcon = Path.GetTempFileName (); // remember to delete file in teardown
|
||||
Path.ChangeExtension (tempFileWithIcon, "ico");
|
||||
|
||||
WriteEmbeddedResource ("32x32.ico", tempFileWithIcon);
|
||||
ResXFileRef fileRef = new ResXFileRef (tempFileWithIcon, typeof (Icon).AssemblyQualifiedName);
|
||||
ResXFileRef fileRef = new ResXFileRef (TestResourceHelper.GetFullPathOfResource ("Test/resources/32x32.ico"), typeof (Icon).AssemblyQualifiedName);
|
||||
ResXDataNode node = new ResXDataNode ("test", fileRef);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void WriteEmbeddedResource (string name, string filename)
|
||||
{
|
||||
const int size = 512;
|
||||
byte [] buffer = new byte [size];
|
||||
int count = 0;
|
||||
|
||||
Stream input = typeof (ResXDataNodeTest).Assembly.
|
||||
GetManifestResourceStream (name);
|
||||
Stream output = File.Open (filename, FileMode.Create);
|
||||
|
||||
try {
|
||||
while ((count = input.Read (buffer, 0, size)) > 0) {
|
||||
output.Write (buffer, 0, count);
|
||||
}
|
||||
} finally {
|
||||
output.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
public ResXDataNode GetNodeEmdeddedBytes1To10 ()
|
||||
{
|
||||
byte [] someBytes = new byte [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
@@ -166,11 +141,6 @@ namespace MonoTests.System.Resources {
|
||||
[TearDown]
|
||||
protected virtual void TearDown ()
|
||||
{
|
||||
if (tempFileWithIcon != null) {
|
||||
File.Delete (tempFileWithIcon);
|
||||
tempFileWithIcon = null;
|
||||
}
|
||||
|
||||
if (tempFileWithSerializable != null) {
|
||||
File.Delete (tempFileWithSerializable);
|
||||
tempFileWithSerializable = null;
|
||||
|
Reference in New Issue
Block a user