diff options
author | csharptest <roger@csharptest.net> | 2011-10-04 13:43:26 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-10-04 13:43:26 -0500 |
commit | eac64a5f7afdfca32476534fd8d0bf69d77002ca (patch) | |
tree | 03a38e9992afd1ffb929f3f830d6054009a9cba2 /src/ProtocolBuffersLite.Test | |
parent | 5e48fef659b571db38be18afb61bea0cffcdfdca (diff) | |
download | protobuf-eac64a5f7afdfca32476534fd8d0bf69d77002ca.tar.gz protobuf-eac64a5f7afdfca32476534fd8d0bf69d77002ca.tar.bz2 protobuf-eac64a5f7afdfca32476534fd8d0bf69d77002ca.zip |
- Upgraded NUnit
- Added StatLight and Silverlight unit testing
- Added copies of all projects for Silverlight
- Integrated Silverlight unit tests in build
Diffstat (limited to 'src/ProtocolBuffersLite.Test')
19 files changed, 573 insertions, 146 deletions
diff --git a/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs b/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs index 2a612a9c..2e5b11e8 100644 --- a/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs @@ -39,14 +39,14 @@ using System.Collections.Generic; using System.IO;
using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class AbstractBuilderLiteTest
{
- [Test]
+ [TestMethod]
public void TestMergeFromCodedInputStream()
{
TestAllTypesLite copy,
@@ -62,10 +62,10 @@ namespace Google.ProtocolBuffers copy = copy.ToBuilder().MergeFrom(ci).Build();
}
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakClear()
{
TestAllTypesLite copy, msg = TestAllTypesLite.DefaultInstance;
@@ -74,10 +74,10 @@ namespace Google.ProtocolBuffers Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());
copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakClear().WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestBuilderLiteMergeFromCodedInputStream()
{
TestAllTypesLite copy,
@@ -89,10 +89,10 @@ namespace Google.ProtocolBuffers copy =
copy.ToBuilder().MergeFrom(CodedInputStream.CreateInstance(new MemoryStream(msg.ToByteArray()))).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestBuilderLiteMergeDelimitedFrom()
{
TestAllTypesLite copy,
@@ -105,10 +105,10 @@ namespace Google.ProtocolBuffers msg.WriteDelimitedTo(s);
s.Position = 0;
copy = copy.ToBuilder().MergeDelimitedFrom(s).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestBuilderLiteMergeDelimitedFromExtensions()
{
TestAllExtensionsLite copy,
@@ -127,11 +127,11 @@ namespace Google.ProtocolBuffers UnitTestLiteProtoFile.RegisterAllExtensions(registry);
copy = copy.ToBuilder().MergeDelimitedFrom(s, registry).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
Assert.AreEqual("Should be merged.", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestBuilderLiteMergeFromStream()
{
TestAllTypesLite copy,
@@ -144,10 +144,10 @@ namespace Google.ProtocolBuffers msg.WriteTo(s);
s.Position = 0;
copy = copy.ToBuilder().MergeFrom(s).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestBuilderLiteMergeFromStreamExtensions()
{
TestAllExtensionsLite copy,
@@ -166,11 +166,11 @@ namespace Google.ProtocolBuffers UnitTestLiteProtoFile.RegisterAllExtensions(registry);
copy = copy.ToBuilder().MergeFrom(s, registry).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
Assert.AreEqual("Should be merged.", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakMergeFromIMessageLite()
{
TestAllTypesLite copy,
@@ -181,10 +181,10 @@ namespace Google.ProtocolBuffers Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());
copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom((IMessageLite) msg).WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakMergeFromByteString()
{
TestAllTypesLite copy,
@@ -195,10 +195,10 @@ namespace Google.ProtocolBuffers Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());
copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(msg.ToByteString()).WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakMergeFromByteStringExtensions()
{
TestAllExtensionsLite copy,
@@ -220,11 +220,11 @@ namespace Google.ProtocolBuffers copy =
(TestAllExtensionsLite)
((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(msg.ToByteString(), registry).WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
Assert.AreEqual("Should be merged.", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakMergeFromCodedInputStream()
{
TestAllTypesLite copy,
@@ -240,10 +240,10 @@ namespace Google.ProtocolBuffers copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(ci).WeakBuild();
}
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakBuildPartial()
{
IBuilderLite builder = TestRequiredLite.CreateBuilder();
@@ -252,10 +252,10 @@ namespace Google.ProtocolBuffers IMessageLite msg = builder.WeakBuildPartial();
Assert.IsFalse(msg.IsInitialized);
- Assert.AreEqual(msg.ToByteArray(), TestRequiredLite.DefaultInstance.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), TestRequiredLite.DefaultInstance.ToByteArray());
}
- [Test, ExpectedException(typeof (UninitializedMessageException))]
+ [TestMethod, ExpectedException(typeof (UninitializedMessageException))]
public void TestIBuilderLiteWeakBuildUninitialized()
{
IBuilderLite builder = TestRequiredLite.CreateBuilder();
@@ -263,7 +263,7 @@ namespace Google.ProtocolBuffers builder.WeakBuild();
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakBuild()
{
IBuilderLite builder = TestRequiredLite.CreateBuilder()
@@ -273,7 +273,7 @@ namespace Google.ProtocolBuffers builder.WeakBuild();
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakClone()
{
TestRequiredLite msg = TestRequiredLite.CreateBuilder()
@@ -281,17 +281,17 @@ namespace Google.ProtocolBuffers Assert.IsTrue(msg.IsInitialized);
IMessageLite copy = ((IBuilderLite) msg.ToBuilder()).WeakClone().WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestIBuilderLiteWeakDefaultInstance()
{
Assert.IsTrue(ReferenceEquals(TestRequiredLite.DefaultInstance,
((IBuilderLite) TestRequiredLite.CreateBuilder()).WeakDefaultInstanceForType));
}
- [Test]
+ [TestMethod]
public void TestGeneratedBuilderLiteAddRange()
{
TestAllTypesLite copy,
@@ -303,7 +303,7 @@ namespace Google.ProtocolBuffers .Build();
copy = msg.DefaultInstanceForType.ToBuilder().MergeFrom(msg).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
}
}
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs b/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs index 5ef9636d..74eed574 100644 --- a/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs @@ -39,14 +39,14 @@ using System.Collections.Generic; using System.IO;
using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class AbstractMessageLiteTest
{
- [Test]
+ [TestMethod]
public void TestMessageLiteToByteString()
{
TestRequiredLite msg = TestRequiredLite.CreateBuilder()
@@ -62,7 +62,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual((int) ExtraEnum.EXLITE_BAZ, b[3]);
}
- [Test]
+ [TestMethod]
public void TestMessageLiteToByteArray()
{
TestRequiredLite msg = TestRequiredLite.CreateBuilder()
@@ -75,7 +75,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(b, copy);
}
- [Test]
+ [TestMethod]
public void TestMessageLiteWriteTo()
{
TestRequiredLite msg = TestRequiredLite.CreateBuilder()
@@ -85,10 +85,10 @@ namespace Google.ProtocolBuffers MemoryStream ms = new MemoryStream();
msg.WriteTo(ms);
- Assert.AreEqual(msg.ToByteArray(), ms.ToArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), ms.ToArray());
}
- [Test]
+ [TestMethod]
public void TestMessageLiteWriteDelimitedTo()
{
TestRequiredLite msg = TestRequiredLite.CreateBuilder()
@@ -104,17 +104,17 @@ namespace Google.ProtocolBuffers Assert.AreEqual(4, buffer[0]);
byte[] msgBytes = new byte[4];
Array.Copy(buffer, 1, msgBytes, 0, 4);
- Assert.AreEqual(msg.ToByteArray(), msgBytes);
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), msgBytes);
}
- [Test]
+ [TestMethod]
public void TestIMessageLiteWeakCreateBuilderForType()
{
IMessageLite msg = TestRequiredLite.DefaultInstance;
Assert.AreEqual(typeof (TestRequiredLite.Builder), msg.WeakCreateBuilderForType().GetType());
}
- [Test]
+ [TestMethod]
public void TestMessageLiteWeakToBuilder()
{
IMessageLite msg = TestRequiredLite.CreateBuilder()
@@ -123,10 +123,10 @@ namespace Google.ProtocolBuffers .Build();
IMessageLite copy = msg.WeakToBuilder().WeakBuild();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestMessageLiteWeakDefaultInstanceForType()
{
IMessageLite msg = TestRequiredLite.DefaultInstance;
diff --git a/src/ProtocolBuffersLite.Test/App.xaml b/src/ProtocolBuffersLite.Test/App.xaml new file mode 100644 index 00000000..d4f1f2e3 --- /dev/null +++ b/src/ProtocolBuffersLite.Test/App.xaml @@ -0,0 +1,8 @@ +<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ x:Class="ProtocolBuffers.SilverlightTest.App"
+ >
+ <Application.Resources>
+
+ </Application.Resources>
+</Application>
diff --git a/src/ProtocolBuffersLite.Test/App.xaml.cs b/src/ProtocolBuffersLite.Test/App.xaml.cs new file mode 100644 index 00000000..0c9fd9e6 --- /dev/null +++ b/src/ProtocolBuffersLite.Test/App.xaml.cs @@ -0,0 +1,60 @@ +using System;
+using System.Windows;
+using Microsoft.Silverlight.Testing;
+
+namespace Google.ProtocolBuffers
+{
+ public partial class App : Application
+ {
+
+ public App()
+ {
+ this.Startup += this.Application_Startup;
+ this.Exit += this.Application_Exit;
+ this.UnhandledException += this.Application_UnhandledException;
+
+ //InitializeComponent();
+ }
+
+ private void Application_Startup(object sender, StartupEventArgs e)
+ {
+ this.RootVisual = UnitTestSystem.CreateTestPage();
+ }
+
+ private void Application_Exit(object sender, EventArgs e)
+ {
+
+ }
+ private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
+ {
+ // If the app is running outside of the debugger then report the exception using
+ // the browser's exception mechanism. On IE this will display it a yellow alert
+ // icon in the status bar and Firefox will display a script error.
+ if (!System.Diagnostics.Debugger.IsAttached)
+ {
+
+ // NOTE: This will allow the application to continue running after an exception has been thrown
+ // but not handled.
+ // For production applications this error handling should be replaced with something that will
+ // report the error to the website and stop the application.
+ e.Handled = true;
+ Deployment.Current.Dispatcher.BeginInvoke(
+ new EventHandler<ApplicationUnhandledExceptionEventArgs>(ReportErrorToDOM),
+ new object[] { sender, e } );
+ }
+ }
+ private void ReportErrorToDOM(object sender, ApplicationUnhandledExceptionEventArgs e)
+ {
+ try
+ {
+ string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
+ errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
+
+ System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");");
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs b/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs index 75580473..65683188 100644 --- a/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs @@ -39,14 +39,14 @@ using System.Collections; using System.Collections.Generic;
using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class ExtendableBuilderLiteTest
{
- [Test]
+ [TestMethod]
public void TestHasExtensionT()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -55,14 +55,14 @@ namespace Google.ProtocolBuffers Assert.IsTrue(builder.HasExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestHasExtensionTMissing()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
Assert.IsFalse(builder.HasExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestGetExtensionCountT()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -73,14 +73,14 @@ namespace Google.ProtocolBuffers Assert.AreEqual(3, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestGetExtensionCountTEmpty()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestGetExtensionTNull()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
@@ -88,7 +88,7 @@ namespace Google.ProtocolBuffers Assert.IsNull(value);
}
- [Test]
+ [TestMethod]
public void TestGetExtensionTValue()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -97,14 +97,14 @@ namespace Google.ProtocolBuffers Assert.AreEqual(3, builder.GetExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestGetExtensionTEmpty()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
Assert.AreEqual(0, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite).Count);
}
- [Test]
+ [TestMethod]
public void TestGetExtensionTList()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -116,7 +116,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(3, values.Count);
}
- [Test]
+ [TestMethod]
public void TestGetExtensionTIndex()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -128,14 +128,14 @@ namespace Google.ProtocolBuffers Assert.AreEqual(i, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, i));
}
- [Test, ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [TestMethod, ExpectedException(typeof (ArgumentOutOfRangeException))]
public void TestGetExtensionTIndexOutOfRange()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0);
}
- [Test]
+ [TestMethod]
public void TestSetExtensionTIndex()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -154,14 +154,14 @@ namespace Google.ProtocolBuffers Assert.AreEqual(5 + i, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, i));
}
- [Test, ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [TestMethod, ExpectedException(typeof (ArgumentOutOfRangeException))]
public void TestSetExtensionTIndexOutOfRange()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
builder.SetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0, -1);
}
- [Test]
+ [TestMethod]
public void TestClearExtensionTList()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -172,7 +172,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestClearExtensionTValue()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -183,7 +183,7 @@ namespace Google.ProtocolBuffers Assert.IsFalse(builder.HasExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestIndexedByDescriptor()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
@@ -195,7 +195,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(123, builder.GetExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestIndexedByDescriptorAndOrdinal()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -209,7 +209,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(123, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0));
}
- [Test, ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [TestMethod, ExpectedException(typeof (ArgumentOutOfRangeException))]
public void TestIndexedByDescriptorAndOrdinalOutOfRange()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
@@ -219,7 +219,7 @@ namespace Google.ProtocolBuffers builder[f, 0] = 123;
}
- [Test]
+ [TestMethod]
public void TestClearFieldByDescriptor()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -231,7 +231,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
}
- [Test]
+ [TestMethod]
public void TestAddRepeatedFieldByDescriptor()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -244,7 +244,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(123, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 1));
}
- [Test]
+ [TestMethod]
public void TestMissingExtensionsLite()
{
const int optionalInt32 = 12345678;
@@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(0, copybits.Length);
}
- [Test]
+ [TestMethod]
public void TestMissingFieldsLite()
{
TestAllTypesLite msg = TestAllTypesLite.CreateBuilder()
diff --git a/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs b/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs index 30e34b93..a7c0f69a 100644 --- a/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs @@ -39,22 +39,23 @@ using System.Collections.Generic; using System.Text;
using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class ExtendableMessageLiteTest
{
- [Test, Ignore("Not implemented, no assertion made"), ExpectedException(typeof (ArgumentException))]
- public void ExtensionWriterInvalidExtension()
- {
- TestPackedExtensionsLite.CreateBuilder()[
- UnitTestLiteProtoFile.OptionalForeignMessageExtensionLite.Descriptor] =
- ForeignMessageLite.DefaultInstance;
- }
-
- [Test]
+ //The lite framework does not make this assertion
+ //[TestMethod, Ignore, ExpectedException(typeof (ArgumentException))]
+ //public void ExtensionWriterInvalidExtension()
+ //{
+ // TestPackedExtensionsLite.CreateBuilder()[
+ // UnitTestLiteProtoFile.OptionalForeignMessageExtensionLite.Descriptor] =
+ // ForeignMessageLite.DefaultInstance;
+ //}
+
+ [TestMethod]
public void ExtensionWriterTestMessages()
{
TestAllExtensionsLite.Builder b = TestAllExtensionsLite.CreateBuilder().SetExtension(
@@ -66,10 +67,10 @@ namespace Google.ProtocolBuffers UnitTestLiteProtoFile.RegisterAllExtensions(registry);
copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry);
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void ExtensionWriterIsInitialized()
{
Assert.IsTrue(ForeignMessageLite.DefaultInstance.IsInitialized);
@@ -79,7 +80,7 @@ namespace Google.ProtocolBuffers .IsInitialized);
}
- [Test]
+ [TestMethod]
public void ExtensionWriterTestSetExtensionLists()
{
TestAllExtensionsLite msg, copy;
@@ -95,13 +96,13 @@ namespace Google.ProtocolBuffers UnitTestLiteProtoFile.RegisterAllExtensions(registry);
copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry);
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_FOO,
copy.GetExtension(UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite, 1));
}
- [Test]
+ [TestMethod]
public void ExtensionWriterTest()
{
TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
@@ -180,7 +181,7 @@ namespace Google.ProtocolBuffers TestAllExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry);
TestAllExtensionsLite copy = copyBuilder.Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.DefaultBoolExtensionLite));
Assert.AreEqual(ByteString.CopyFromUtf8("123"),
@@ -323,7 +324,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedUint64ExtensionLite, 1));
}
- [Test]
+ [TestMethod]
public void ExtensionWriterTestPacked()
{
TestPackedExtensionsLite msg = BuildPackedExtensions();
@@ -335,12 +336,12 @@ namespace Google.ProtocolBuffers TestPackedExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry);
TestPackedExtensionsLite copy = copyBuilder.Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
AssertPackedExtensions(copy);
}
- [Test]
+ [TestMethod]
public void TestUnpackedAndPackedExtensions()
{
TestPackedExtensionsLite original = BuildPackedExtensions();
@@ -355,18 +356,18 @@ namespace Google.ProtocolBuffers TestPackedExtensionsLite packed = TestPackedExtensionsLite.ParseFrom(unpacked.ToByteArray(), registry);
Assert.AreEqual(original, packed);
- Assert.AreEqual(original.ToByteArray(), packed.ToByteArray());
+ TestUtil.AssertBytesEqual(original.ToByteArray(), packed.ToByteArray());
AssertPackedExtensions(packed);
}
- [Test]
+ [TestMethod]
public void TestUnpackedFromPackedInput()
{
byte[] packedData = BuildPackedExtensions().ToByteArray();
TestUnpackedTypesLite unpacked = TestUnpackedTypesLite.ParseFrom(packedData);
TestPackedTypesLite packed = TestPackedTypesLite.ParseFrom(unpacked.ToByteArray());
- Assert.AreEqual(packedData, packed.ToByteArray());
+ TestUtil.AssertBytesEqual(packedData, packed.ToByteArray());
unpacked = TestUnpackedTypesLite.ParseFrom(packed.ToByteArray());
diff --git a/src/ProtocolBuffersLite.Test/InteropLiteTest.cs b/src/ProtocolBuffersLite.Test/InteropLiteTest.cs index c49e0350..37739d2f 100644 --- a/src/ProtocolBuffersLite.Test/InteropLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/InteropLiteTest.cs @@ -38,14 +38,14 @@ using System; using System.Collections.Generic;
using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class InteropLiteTest
{
- [Test]
+ [TestMethod]
public void TestConvertFromFullMinimal()
{
TestInteropPerson person = TestInteropPerson.CreateBuilder()
@@ -56,10 +56,10 @@ namespace Google.ProtocolBuffers TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(person.ToByteArray());
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestConvertFromFullComplete()
{
TestInteropPerson person = TestInteropPerson.CreateBuilder()
@@ -82,10 +82,10 @@ namespace Google.ProtocolBuffers TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(person.ToByteArray(), registry);
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestConvertFromLiteMinimal()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
@@ -96,10 +96,10 @@ namespace Google.ProtocolBuffers TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray());
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestConvertFromLiteComplete()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
@@ -122,7 +122,7 @@ namespace Google.ProtocolBuffers TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry);
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
}
public ByteString AllBytes
@@ -136,7 +136,7 @@ namespace Google.ProtocolBuffers }
}
- [Test]
+ [TestMethod]
public void TestCompareStringValues()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
@@ -147,7 +147,7 @@ namespace Google.ProtocolBuffers .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build())
.AddPhone(
TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber(
- System.Text.Encoding.ASCII.GetString(AllBytes.ToByteArray())).Build())
+ System.Text.Encoding.UTF8.GetString(AllBytes.ToByteArray(), 0, AllBytes.Length)).Build())
.AddAddresses(
TestInteropPersonLite.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland")
.SetState("NA").SetZip(12345).Build())
@@ -161,7 +161,7 @@ namespace Google.ProtocolBuffers TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry);
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
TestInteropPerson.Builder copyBuilder = TestInteropPerson.CreateBuilder();
TextFormat.Merge(
@@ -169,7 +169,7 @@ namespace Google.ProtocolBuffers "[protobuf_unittest_extra.employee_id]"), registry, copyBuilder);
copy = copyBuilder.Build();
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
string liteText = person.ToString().TrimEnd().Replace("\r", "");
string fullText = copy.ToString().TrimEnd().Replace("\r", "");
diff --git a/src/ProtocolBuffersLite.Test/LiteTest.cs b/src/ProtocolBuffersLite.Test/LiteTest.cs index f1cb949a..3561876b 100644 --- a/src/ProtocolBuffersLite.Test/LiteTest.cs +++ b/src/ProtocolBuffersLite.Test/LiteTest.cs @@ -39,7 +39,7 @@ using System.Collections.Generic; using System.IO;
using Google.ProtocolBuffers.Descriptors;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
@@ -47,10 +47,10 @@ namespace Google.ProtocolBuffers /// Miscellaneous tests for message operations that apply to both
/// generated and dynamic messages.
/// </summary>
- [TestFixture]
+ [TestClass]
public class LiteTest
{
- [Test]
+ [TestMethod]
public void TestLite()
{
// Since lite messages are a subset of regular messages, we can mostly
@@ -79,7 +79,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(7, message2.OptionalNestedMessage.Bb);
}
- [Test]
+ [TestMethod]
public void TestLiteExtensions()
{
// TODO(kenton): Unlike other features of the lite library, extensions are
diff --git a/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs b/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs index 47014f34..c65cb7f1 100644 --- a/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs +++ b/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs @@ -35,16 +35,16 @@ #endregion
using System.IO;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using Google.ProtocolBuffers.TestProtos;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class MissingFieldAndExtensionTest
{
- [Test]
+ [TestMethod]
public void TestRecoverMissingExtensions()
{
const int optionalInt32 = 12345678;
@@ -66,7 +66,7 @@ namespace Google.ProtocolBuffers //Even though copy does not understand the typees they serialize correctly
byte[] copybits = copy.ToByteArray();
- Assert.AreEqual(bits, copybits);
+ TestUtil.AssertBytesEqual(bits, copybits);
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnitTestProtoFile.RegisterAllExtensions(registry);
@@ -77,20 +77,20 @@ namespace Google.ProtocolBuffers Assert.AreEqual(3, copy.GetExtensionCount(UnitTestProtoFile.RepeatedDoubleExtension));
Assert.AreEqual(msg, copy);
- Assert.AreEqual(bits, copy.ToByteArray());
+ TestUtil.AssertBytesEqual(bits, copy.ToByteArray());
//If we modify the object this should all continue to work as before
copybits = copy.ToBuilder().Build().ToByteArray();
- Assert.AreEqual(bits, copybits);
+ TestUtil.AssertBytesEqual(bits, copybits);
//If we replace extension the object this should all continue to work as before
copybits = copy.ToBuilder()
.SetExtension(UnitTestProtoFile.OptionalInt32Extension, optionalInt32)
.Build().ToByteArray();
- Assert.AreEqual(bits, copybits);
+ TestUtil.AssertBytesEqual(bits, copybits);
}
- [Test]
+ [TestMethod]
public void TestRecoverMissingFields()
{
TestMissingFieldsA msga = TestMissingFieldsA.CreateBuilder()
@@ -109,7 +109,7 @@ namespace Google.ProtocolBuffers msgb.UnknownFields[TestMissingFieldsA.EmailFieldNumber].LengthDelimitedList[0].ToStringUtf8());
//serializes exactly the same (at least for this simple example)
- Assert.AreEqual(msga.ToByteArray(), msgb.ToByteArray());
+ TestUtil.AssertBytesEqual(msga.ToByteArray(), msgb.ToByteArray());
Assert.AreEqual(msga, TestMissingFieldsA.ParseFrom(msgb.ToByteArray()));
//now re-create an exact copy of A from serialized B
@@ -147,7 +147,7 @@ namespace Google.ProtocolBuffers ());
}
- [Test]
+ [TestMethod]
public void TestRecoverMissingMessage()
{
TestMissingFieldsA.Types.SubA suba =
@@ -170,7 +170,7 @@ namespace Google.ProtocolBuffers ());
//serializes exactly the same (at least for this simple example)
- Assert.AreEqual(msga.ToByteArray(), msgb.ToByteArray());
+ TestUtil.AssertBytesEqual(msga.ToByteArray(), msgb.ToByteArray());
Assert.AreEqual(msga, TestMissingFieldsA.ParseFrom(msgb.ToByteArray()));
//now re-create an exact copy of A from serialized B
@@ -194,7 +194,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual("Name", copya.Name);
Assert.AreEqual(suba, copya.TestA);
Assert.AreEqual(1, copya.UnknownFields.FieldDictionary.Count);
- Assert.AreEqual(subb.ToByteArray(),
+ TestUtil.AssertBytesEqual(subb.ToByteArray(),
copya.UnknownFields[TestMissingFieldsB.TestBFieldNumber].LengthDelimitedList[0].ToByteArray());
//Lastly we can even still trip back to type B and see all fields:
@@ -206,7 +206,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(1, copyb.UnknownFields.FieldDictionary.Count);
}
- [Test]
+ [TestMethod]
public void TestRestoreFromOtherType()
{
TestInteropPerson person = TestInteropPerson.CreateBuilder()
@@ -234,7 +234,7 @@ namespace Google.ProtocolBuffers TestInteropPerson copy = TestInteropPerson.ParseFrom(temp.ToByteArray(), registry);
Assert.AreEqual(person, copy);
- Assert.AreEqual(person.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
}
}
}
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml b/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml new file mode 100644 index 00000000..a9552327 --- /dev/null +++ b/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml @@ -0,0 +1,6 @@ +<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+>
+ <Deployment.Parts>
+ </Deployment.Parts>
+</Deployment>
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test(Silverlight).csproj b/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test(Silverlight).csproj new file mode 100644 index 00000000..b852f233 --- /dev/null +++ b/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test(Silverlight).csproj @@ -0,0 +1,147 @@ +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug_Silverlight</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C56950B0-9F97-4250-8945-4B3C2D441FEA}</ProjectGuid>
+ <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Google.ProtocolBuffers</RootNamespace>
+ <AssemblyName>Google.ProtocolBuffersLite.Test</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <SilverlightApplication>true</SilverlightApplication>
+ <SupportedCultures>
+ </SupportedCultures>
+ <XapOutputs>true</XapOutputs>
+ <GenerateSilverlightManifest>true</GenerateSilverlightManifest>
+ <XapFilename>Google.ProtocolBuffersLite.Test.xap</XapFilename>
+ <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
+ <SilverlightAppEntry>Google.ProtocolBuffers.App</SilverlightAppEntry>
+ <TestPageFileName>TestPage.html</TestPageFileName>
+ <CreateTestPage>true</CreateTestPage>
+ <ValidateXaml>false</ValidateXaml>
+ <ThrowErrorsInValidation>false</ThrowErrorsInValidation>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <SilverlightVersion Condition=" '$(SilverlightVersion)' == '' ">v2.0</SilverlightVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_Silverlight|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug_Silverlight</OutputPath>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>3021</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Silverlight|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release_Silverlight</OutputPath>
+ <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>3021</NoWarn>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Silverlight.Testing, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Microsoft.Silverlight.Testing\April2010\Microsoft.Silverlight.Testing.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Microsoft.Silverlight.Testing\April2010\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Windows" />
+ <Reference Include="mscorlib" />
+ <Reference Include="system" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Windows.Browser" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
+ <Link>Properties\AssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\ProtocolBuffers.Test\TestRpcForMimeTypes.cs">
+ <Link>TestRpcForMimeTypes.cs</Link>
+ </Compile>
+ <Compile Include="..\ProtocolBuffers.Test\TestRpcGenerator.cs">
+ <Link>TestRpcGenerator.cs</Link>
+ </Compile>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="AbstractBuilderLiteTest.cs" />
+ <Compile Include="AbstractMessageLiteTest.cs" />
+ <Compile Include="ExtendableBuilderLiteTest.cs" />
+ <Compile Include="ExtendableMessageLiteTest.cs" />
+ <Compile Include="LiteTest.cs" />
+ <Compile Include="SerializableAttribute.cs" />
+ <Compile Include="TestLiteByApi.cs" />
+ <Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestImportLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestLiteProtoFile.cs" />
+ <Compile Include="TestUtil.cs" />
+ <Compile Include="TestProtos\UnitTestRpcInteropLite.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ProtocolBuffers.Serialization\ProtocolBuffersLite.Serialization%28Silverlight%29.csproj">
+ <Project>{B6CDC03B-EBBD-4F38-9F84-736EC0948090}</Project>
+ <Name>ProtocolBuffersLite.Serialization%28Silverlight%29</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ProtocolBuffers\ProtocolBuffersLite%28Silverlight%29.csproj">
+ <Project>{2275EE6B-195B-485C-B6F6-CCA01C1B5AE0}</Project>
+ <Name>ProtocolBuffersLite%28Silverlight%29</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Properties\AppManifest.xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
+ <SilverlightProjectProperties />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+</Project>
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj b/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj index b846ff1a..d10aac15 100644 --- a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj +++ b/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj @@ -39,9 +39,9 @@ <NoStdLib>true</NoStdLib>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\NUnit 2.2.8.0\nunit.framework.dll</HintPath>
+ <HintPath>..\..\lib\NUnit\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks, Version=3.5.0.2, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -53,6 +53,9 @@ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="..\..\lib\NUnit-config\Microsoft.VisualStudio.TestTools.cs">
+ <Link>Microsoft.VisualStudio.TestTools.cs</Link>
+ </Compile>
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
@@ -73,6 +76,7 @@ <Compile Include="TestProtos\UnitTestImportLiteProtoFile.cs" />
<Compile Include="TestProtos\UnitTestLiteProtoFile.cs" />
<Compile Include="TestProtos\UnitTestRpcInteropLite.cs" />
+ <Compile Include="TestUtil.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProtocolBuffers.Serialization\ProtocolBuffersLite.Serialization.csproj">
@@ -93,4 +97,10 @@ <Target Name="AfterBuild">
</Target>
-->
+ <PropertyGroup>
+ <StartAction>Program</StartAction>
+ <StartProgram>$(ProjectDir)..\..\lib\NUnit\tools\nunit-console.exe</StartProgram>
+ <StartArguments>/nologo /noshadow /labels /wait $(AssemblyName).dll</StartArguments>
+ <StartWorkingDirectory>$(ProjectDir)$(OutputPath)</StartWorkingDirectory>
+ </PropertyGroup>
</Project>
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test(Silverlight).csproj b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test(Silverlight).csproj new file mode 100644 index 00000000..424ee70f --- /dev/null +++ b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test(Silverlight).csproj @@ -0,0 +1,142 @@ +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug_Silverlight</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{63B8D05E-4581-4B92-B8D5-77E702535C7F}</ProjectGuid>
+ <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Google.ProtocolBuffers</RootNamespace>
+ <AssemblyName>Google.ProtocolBuffersLiteMixed.Test</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <SilverlightApplication>true</SilverlightApplication>
+ <SupportedCultures>
+ </SupportedCultures>
+ <XapOutputs>true</XapOutputs>
+ <GenerateSilverlightManifest>true</GenerateSilverlightManifest>
+ <XapFilename>Google.ProtocolBuffersLiteMixed.Test.xap</XapFilename>
+ <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
+ <SilverlightAppEntry>Google.ProtocolBuffers.App</SilverlightAppEntry>
+ <TestPageFileName>TestPage.html</TestPageFileName>
+ <CreateTestPage>true</CreateTestPage>
+ <ValidateXaml>false</ValidateXaml>
+ <ThrowErrorsInValidation>false</ThrowErrorsInValidation>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <SilverlightVersion Condition=" '$(SilverlightVersion)' == '' ">v2.0</SilverlightVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_Silverlight|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug_Silverlight</OutputPath>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>3021</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Silverlight|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release_Silverlight</OutputPath>
+ <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>3021</NoWarn>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Silverlight.Testing, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Microsoft.Silverlight.Testing\April2010\Microsoft.Silverlight.Testing.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Microsoft.Silverlight.Testing\April2010\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Windows" />
+ <Reference Include="mscorlib" />
+ <Reference Include="system" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Windows.Browser" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
+ <Link>Properties\AssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="AbstractBuilderLiteTest.cs" />
+ <Compile Include="AbstractMessageLiteTest.cs" />
+ <Compile Include="ExtendableBuilderLiteTest.cs" />
+ <Compile Include="ExtendableMessageLiteTest.cs" />
+ <Compile Include="InteropLiteTest.cs" />
+ <Compile Include="LiteTest.cs" />
+ <Compile Include="MissingFieldAndExtensionTest.cs" />
+ <Compile Include="SerializableAttribute.cs" />
+ <Compile Include="TestLiteByApi.cs" />
+ <Compile Include="TestProtos\UnitTestExtrasFullProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestImportLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestImportProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestLiteImportNonLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestLiteProtoFile.cs" />
+ <Compile Include="TestProtos\UnitTestProtoFile.cs" />
+ <Compile Include="TestUtil.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers%28Silverlight%29.csproj">
+ <Project>{7E4E681E-5D09-43FB-8D9E-35A454730A85}</Project>
+ <Name>ProtocolBuffers%28Silverlight%29</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Properties\AppManifest.xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
+ <SilverlightProjectProperties />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+</Project>
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj index d61d6651..b0a2b7c1 100644 --- a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj +++ b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj @@ -39,9 +39,9 @@ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\NUnit 2.2.8.0\nunit.framework.dll</HintPath>
+ <HintPath>..\..\lib\NUnit\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks, Version=3.5.0.2, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -53,6 +53,9 @@ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="..\..\lib\NUnit-config\Microsoft.VisualStudio.TestTools.cs">
+ <Link>Microsoft.VisualStudio.TestTools.cs</Link>
+ </Compile>
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
@@ -71,6 +74,7 @@ <Compile Include="TestProtos\UnitTestLiteImportNonLiteProtoFile.cs" />
<Compile Include="TestProtos\UnitTestLiteProtoFile.cs" />
<Compile Include="TestProtos\UnitTestProtoFile.cs" />
+ <Compile Include="TestUtil.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers.csproj">
@@ -86,4 +90,10 @@ <Target Name="AfterBuild">
</Target>
-->
+ <PropertyGroup>
+ <StartAction>Program</StartAction>
+ <StartProgram>$(ProjectDir)..\..\lib\NUnit\tools\nunit-console.exe</StartProgram>
+ <StartArguments>/nologo /noshadow /labels /wait $(AssemblyName).dll</StartArguments>
+ <StartWorkingDirectory>$(ProjectDir)$(OutputPath)</StartWorkingDirectory>
+ </PropertyGroup>
</Project>
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/SerializableAttribute.cs b/src/ProtocolBuffersLite.Test/SerializableAttribute.cs new file mode 100644 index 00000000..04fcdcba --- /dev/null +++ b/src/ProtocolBuffersLite.Test/SerializableAttribute.cs @@ -0,0 +1,12 @@ +#if SILVERLIGHT
+
+namespace System
+{
+ [AttributeUsage(AttributeTargets.Class)]
+ public class SerializableAttribute : Attribute
+ {
+ public SerializableAttribute () : base() { }
+ }
+}
+
+#endif
diff --git a/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs b/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs index 7c12ef40..a688a909 100644 --- a/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs @@ -5,11 +5,11 @@ using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class SerializableLiteTest
{
/// <summary>
@@ -18,7 +18,7 @@ namespace Google.ProtocolBuffers public static readonly ISerializable CompileTimeCheckSerializableMessage = TestRequiredLite.DefaultInstance;
public static readonly ISerializable CompileTimeCheckSerializableBuilder = new TestRequiredLite.Builder();
- [Test]
+ [TestMethod]
public void TestPlainMessage()
{
TestRequiredLite message = TestRequiredLite.CreateBuilder()
@@ -34,7 +34,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(message, copy);
}
- [Test]
+ [TestMethod]
public void TestPlainBuilder()
{
TestRequiredLite.Builder builder = TestRequiredLite.CreateBuilder()
diff --git a/src/ProtocolBuffersLite.Test/TestLiteByApi.cs b/src/ProtocolBuffersLite.Test/TestLiteByApi.cs index 5fee2ecb..ce373028 100644 --- a/src/ProtocolBuffersLite.Test/TestLiteByApi.cs +++ b/src/ProtocolBuffersLite.Test/TestLiteByApi.cs @@ -35,14 +35,14 @@ #endregion
using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Google.ProtocolBuffers
{
- [TestFixture]
+ [TestClass]
public class TestLiteByApi
{
- [Test]
+ [TestMethod]
public void TestAllTypesEquality()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
@@ -57,7 +57,7 @@ namespace Google.ProtocolBuffers Assert.IsTrue(msg.Equals(copy));
}
- [Test]
+ [TestMethod]
public void TestEqualityOnExtensions()
{
TestAllExtensionsLite msg = TestAllExtensionsLite.DefaultInstance;
@@ -72,13 +72,13 @@ namespace Google.ProtocolBuffers Assert.IsTrue(msg.Equals(copy));
}
- [Test]
+ [TestMethod]
public void TestAllTypesToString()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
TestAllTypesLite copy = msg.ToBuilder().Build();
Assert.AreEqual(msg.ToString(), copy.ToString());
- Assert.IsEmpty(msg.ToString());
+ Assert.AreEqual(0, msg.ToString().Length);
msg = msg.ToBuilder().SetOptionalInt32(-1).Build();
Assert.AreEqual("optional_int32: -1", msg.ToString().TrimEnd());
msg = msg.ToBuilder().SetOptionalString("abc123").Build();
@@ -86,16 +86,16 @@ namespace Google.ProtocolBuffers msg.ToString().Replace("\r", "").TrimEnd());
}
- [Test]
+ [TestMethod]
public void TestAllTypesDefaultedRoundTrip()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
Assert.IsTrue(msg.IsInitialized);
TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
- [Test]
+ [TestMethod]
public void TestAllTypesModifiedRoundTrip()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
@@ -115,7 +115,7 @@ namespace Google.ProtocolBuffers .AddRepeatedGroup(TestAllTypesLite.Types.RepeatedGroup.CreateBuilder().SetA('A').Build())
;
TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build();
- Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
+ TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
}
}
}
\ No newline at end of file diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs index 25f48840..535f21e6 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs @@ -1319,7 +1319,7 @@ namespace Google.ProtocolBuffers.TestProtos { public SearchService(pb::IRpcDispatch dispatch) : this(dispatch, true) {
}
public SearchService(pb::IRpcDispatch dispatch, bool dispose) {
- if (null == (this.dispatch = dispatch)) throw new global::System.ArgumentNullException();
+ pb::ThrowHelper.ThrowIfNull(this.dispatch = dispatch, "dispatch");
this.dispose = dispose && dispatch is global::System.IDisposable;
}
@@ -1349,7 +1349,7 @@ namespace Google.ProtocolBuffers.TestProtos { public Dispatch(ISearchService implementation) : this(implementation, true) {
}
public Dispatch(ISearchService implementation, bool dispose) {
- if (null == (this.implementation = implementation)) throw new global::System.ArgumentNullException();
+ pb::ThrowHelper.ThrowIfNull(this.implementation = implementation, "implementation");
this.dispose = dispose && implementation is global::System.IDisposable;
}
@@ -1363,7 +1363,7 @@ namespace Google.ProtocolBuffers.TestProtos { switch(methodName) {
case "Search": return response.MergeFrom(implementation.Search((global::Google.ProtocolBuffers.TestProtos.SearchRequest)request)).Build();
case "RefineSearch": return response.MergeFrom(implementation.RefineSearch((global::Google.ProtocolBuffers.TestProtos.RefineSearchRequest)request)).Build();
- default: throw new global::System.MissingMethodException(typeof(ISearchService).FullName, methodName);
+ default: throw pb::ThrowHelper.CreateMissingMethod(typeof(ISearchService), methodName);
}
}
}
@@ -1381,7 +1381,7 @@ namespace Google.ProtocolBuffers.TestProtos { public ServerStub(pb::IRpcDispatch implementation) : this(implementation, true) {
}
public ServerStub(pb::IRpcDispatch implementation, bool dispose) {
- if (null == (this.implementation = implementation)) throw new global::System.ArgumentNullException();
+ pb::ThrowHelper.ThrowIfNull(this.implementation = implementation, "implementation");
this.dispose = dispose && implementation is global::System.IDisposable;
}
@@ -1393,7 +1393,7 @@ namespace Google.ProtocolBuffers.TestProtos { switch(methodName) {
case "Search": return implementation.CallMethod(methodName, global::Google.ProtocolBuffers.TestProtos.SearchRequest.ParseFrom(input, registry), global::Google.ProtocolBuffers.TestProtos.SearchResponse.CreateBuilder());
case "RefineSearch": return implementation.CallMethod(methodName, global::Google.ProtocolBuffers.TestProtos.RefineSearchRequest.ParseFrom(input, registry), global::Google.ProtocolBuffers.TestProtos.SearchResponse.CreateBuilder());
- default: throw new global::System.MissingMethodException(typeof(ISearchService).FullName, methodName);
+ default: throw pb::ThrowHelper.CreateMissingMethod(typeof(ISearchService), methodName);
}
}
}
diff --git a/src/ProtocolBuffersLite.Test/TestUtil.cs b/src/ProtocolBuffersLite.Test/TestUtil.cs new file mode 100644 index 00000000..44c09b9c --- /dev/null +++ b/src/ProtocolBuffersLite.Test/TestUtil.cs @@ -0,0 +1,31 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Google.ProtocolBuffers
+{
+ class TestUtil
+ {
+ internal static void AssertBytesEqual(byte[] a, byte[] b)
+ {
+ if (a == null || b == null)
+ {
+ Assert.AreEqual<object>(a, b);
+ }
+ else
+ {
+ Assert.AreEqual(a.Length, b.Length, "The byte[] is not of the expected length.");
+
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] != b[i])
+ {
+ Assert.AreEqual(a[i], b[i], "Byte[] differs at index " + i);
+ }
+ }
+ }
+ }
+
+ }
+}
|