From 2e89071876750487160fef06295143837d571cd1 Mon Sep 17 00:00:00 2001 From: csharptest Date: Sat, 1 Oct 2011 15:54:22 -0500 Subject: [PATCH] Changed the resource loading in unit tests --- .../Compatibility/TestResources.Designer.cs | 77 ----------- .../Compatibility/TestResources.cs | 42 ++++++ .../Compatibility/TestResources.resx | 127 ------------------ .../ProtocolBuffers.Test.csproj | 16 +-- 4 files changed, 45 insertions(+), 217 deletions(-) delete mode 100644 src/ProtocolBuffers.Test/Compatibility/TestResources.Designer.cs create mode 100644 src/ProtocolBuffers.Test/Compatibility/TestResources.cs delete mode 100644 src/ProtocolBuffers.Test/Compatibility/TestResources.resx diff --git a/src/ProtocolBuffers.Test/Compatibility/TestResources.Designer.cs b/src/ProtocolBuffers.Test/Compatibility/TestResources.Designer.cs deleted file mode 100644 index 1441cf39e3..0000000000 --- a/src/ProtocolBuffers.Test/Compatibility/TestResources.Designer.cs +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.5446 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Google.ProtocolBuffers.Compatibility { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class TestResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal TestResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Google.ProtocolBuffers.Compatibility.TestResources", typeof(TestResources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - internal static byte[] google_message1 { - get { - object obj = ResourceManager.GetObject("google_message1", resourceCulture); - return ((byte[])(obj)); - } - } - - internal static byte[] google_message2 { - get { - object obj = ResourceManager.GetObject("google_message2", resourceCulture); - return ((byte[])(obj)); - } - } - } -} diff --git a/src/ProtocolBuffers.Test/Compatibility/TestResources.cs b/src/ProtocolBuffers.Test/Compatibility/TestResources.cs new file mode 100644 index 0000000000..2581c7bfbb --- /dev/null +++ b/src/ProtocolBuffers.Test/Compatibility/TestResources.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using NUnit.Framework; + +namespace Google.ProtocolBuffers.Compatibility +{ + static class TestResources + { + public static byte[] google_message1 + { + get + { + Stream resource = typeof(TestResources).Assembly.GetManifestResourceStream( + typeof(TestResources).Namespace + ".google_message1.dat"); + + Assert.IsNotNull(resource, "Unable to the locate resource: google_message1"); + + byte[] bytes = new byte[resource.Length]; + int amtRead = resource.Read(bytes, 0, bytes.Length); + Assert.AreEqual(bytes.Length, amtRead); + return bytes; + } + } + public static byte[] google_message2 + { + get + { + Stream resource = typeof(TestResources).Assembly.GetManifestResourceStream( + typeof(TestResources).Namespace + ".google_message2.dat"); + + Assert.IsNotNull(resource, "Unable to the locate resource: google_message2"); + + byte[] bytes = new byte[resource.Length]; + int amtRead = resource.Read(bytes, 0, bytes.Length); + Assert.AreEqual(bytes.Length, amtRead); + return bytes; + } + } + } +} diff --git a/src/ProtocolBuffers.Test/Compatibility/TestResources.resx b/src/ProtocolBuffers.Test/Compatibility/TestResources.resx deleted file mode 100644 index 0481d38805..0000000000 --- a/src/ProtocolBuffers.Test/Compatibility/TestResources.resx +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - google_message1.dat;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - google_message2.dat;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index e720ce0056..8000e7d204 100644 --- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -81,11 +81,7 @@ - - True - True - TestResources.resx - + @@ -163,14 +159,8 @@ - - - - - - ResXFileCodeGenerator - TestResources.Designer.cs - + +