diff options
author | Jon Skeet <skeet@pobox.com> | 2015-04-30 14:51:42 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-04-30 14:51:42 +0100 |
commit | 0884b77975146be5d0557b254fbeab940cda641a (patch) | |
tree | eee4106598d0faf92b566f7e03930f25df38a56c /csharp/src/ProtocolBuffers.Test/ReflectionTester.cs | |
parent | 151018e888927f4e89e325af013613cc1b08196c (diff) | |
parent | c56475088d2d36d29a2640f35b9a8621796c051c (diff) | |
download | protobuf-0884b77975146be5d0557b254fbeab940cda641a.tar.gz protobuf-0884b77975146be5d0557b254fbeab940cda641a.tar.bz2 protobuf-0884b77975146be5d0557b254fbeab940cda641a.zip |
Merge pull request #324 from jskeet/csharp
Change to using xUnit for all unit tests, and fetch that via NuGet.
Diffstat (limited to 'csharp/src/ProtocolBuffers.Test/ReflectionTester.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers.Test/ReflectionTester.cs | 958 |
1 files changed, 479 insertions, 479 deletions
diff --git a/csharp/src/ProtocolBuffers.Test/ReflectionTester.cs b/csharp/src/ProtocolBuffers.Test/ReflectionTester.cs index 5385d316..5fa22fef 100644 --- a/csharp/src/ProtocolBuffers.Test/ReflectionTester.cs +++ b/csharp/src/ProtocolBuffers.Test/ReflectionTester.cs @@ -37,7 +37,7 @@ using System;
using Google.ProtocolBuffers.Descriptors;
using Google.ProtocolBuffers.TestProtos;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Xunit;
#pragma warning disable 618 // Disable warning about obsolete use miss-matched assert arguments
@@ -97,7 +97,7 @@ namespace Google.ProtocolBuffers this.extensionRegistry = extensionRegistry;
this.file = baseDescriptor.File;
- Assert.AreEqual(1, file.Dependencies.Count);
+ Assert.Equal(1, file.Dependencies.Count);
this.importFile = file.Dependencies[0];
MessageDescriptor testAllTypes;
@@ -108,7 +108,7 @@ namespace Google.ProtocolBuffers else
{
testAllTypes = file.FindTypeByName<MessageDescriptor>("TestAllTypes");
- Assert.IsNotNull(testAllTypes);
+ Assert.NotNull(testAllTypes);
}
if (extensionRegistry == null)
@@ -136,14 +136,14 @@ namespace Google.ProtocolBuffers this.foreignEnum = file.FindTypeByName<EnumDescriptor>("ForeignEnum");
this.importEnum = importFile.FindTypeByName<EnumDescriptor>("ImportEnum");
- Assert.IsNotNull(optionalGroup);
- Assert.IsNotNull(repeatedGroup);
- Assert.IsNotNull(nestedMessage);
- Assert.IsNotNull(foreignMessage);
- Assert.IsNotNull(importMessage);
- Assert.IsNotNull(nestedEnum);
- Assert.IsNotNull(foreignEnum);
- Assert.IsNotNull(importEnum);
+ Assert.NotNull(optionalGroup);
+ Assert.NotNull(repeatedGroup);
+ Assert.NotNull(nestedMessage);
+ Assert.NotNull(foreignMessage);
+ Assert.NotNull(importMessage);
+ Assert.NotNull(nestedEnum);
+ Assert.NotNull(foreignEnum);
+ Assert.NotNull(importEnum);
this.nestedB = nestedMessage.FindDescriptor<FieldDescriptor>("bb");
this.foreignC = foreignMessage.FindDescriptor<FieldDescriptor>("c");
@@ -161,20 +161,20 @@ namespace Google.ProtocolBuffers this.groupA = optionalGroup.FindDescriptor<FieldDescriptor>("a");
this.repeatedGroupA = repeatedGroup.FindDescriptor<FieldDescriptor>("a");
- Assert.IsNotNull(groupA);
- Assert.IsNotNull(repeatedGroupA);
- Assert.IsNotNull(nestedB);
- Assert.IsNotNull(foreignC);
- Assert.IsNotNull(importD);
- Assert.IsNotNull(nestedFoo);
- Assert.IsNotNull(nestedBar);
- Assert.IsNotNull(nestedBaz);
- Assert.IsNotNull(foreignFoo);
- Assert.IsNotNull(foreignBar);
- Assert.IsNotNull(foreignBaz);
- Assert.IsNotNull(importFoo);
- Assert.IsNotNull(importBar);
- Assert.IsNotNull(importBaz);
+ Assert.NotNull(groupA);
+ Assert.NotNull(repeatedGroupA);
+ Assert.NotNull(nestedB);
+ Assert.NotNull(foreignC);
+ Assert.NotNull(importD);
+ Assert.NotNull(nestedFoo);
+ Assert.NotNull(nestedBar);
+ Assert.NotNull(nestedBaz);
+ Assert.NotNull(foreignFoo);
+ Assert.NotNull(foreignBar);
+ Assert.NotNull(foreignBaz);
+ Assert.NotNull(importFoo);
+ Assert.NotNull(importBar);
+ Assert.NotNull(importBaz);
}
/// <summary>
@@ -216,7 +216,7 @@ namespace Google.ProtocolBuffers {
result = file.FindTypeByName<FieldDescriptor>(name + "_extension");
}
- Assert.IsNotNull(result);
+ Assert.NotNull(result);
return result;
}
@@ -233,8 +233,8 @@ namespace Google.ProtocolBuffers else
{
ExtensionInfo extension = extensionRegistry[field.ContainingType, field.FieldNumber];
- Assert.IsNotNull(extension);
- Assert.IsNotNull(extension.DefaultInstance);
+ Assert.NotNull(extension);
+ Assert.NotNull(extension.DefaultInstance);
return (IBuilder) extension.DefaultInstance.WeakCreateBuilderForType();
}
}
@@ -449,199 +449,199 @@ namespace Google.ProtocolBuffers /// </summary>
public void AssertAllFieldsSetViaReflection(IMessage message)
{
- Assert.IsTrue(message.HasField(f("optional_int32")));
- Assert.IsTrue(message.HasField(f("optional_int64")));
- Assert.IsTrue(message.HasField(f("optional_uint32")));
- Assert.IsTrue(message.HasField(f("optional_uint64")));
- Assert.IsTrue(message.HasField(f("optional_sint32")));
- Assert.IsTrue(message.HasField(f("optional_sint64")));
- Assert.IsTrue(message.HasField(f("optional_fixed32")));
- Assert.IsTrue(message.HasField(f("optional_fixed64")));
- Assert.IsTrue(message.HasField(f("optional_sfixed32")));
- Assert.IsTrue(message.HasField(f("optional_sfixed64")));
- Assert.IsTrue(message.HasField(f("optional_float")));
- Assert.IsTrue(message.HasField(f("optional_double")));
- Assert.IsTrue(message.HasField(f("optional_bool")));
- Assert.IsTrue(message.HasField(f("optional_string")));
- Assert.IsTrue(message.HasField(f("optional_bytes")));
-
- Assert.IsTrue(message.HasField(f("optionalgroup")));
- Assert.IsTrue(message.HasField(f("optional_nested_message")));
- Assert.IsTrue(message.HasField(f("optional_foreign_message")));
- Assert.IsTrue(message.HasField(f("optional_import_message")));
-
- Assert.IsTrue(((IMessage) message[f("optionalgroup")]).HasField(groupA));
- Assert.IsTrue(((IMessage) message[f("optional_nested_message")]).HasField(nestedB));
- Assert.IsTrue(((IMessage) message[f("optional_foreign_message")]).HasField(foreignC));
- Assert.IsTrue(((IMessage) message[f("optional_import_message")]).HasField(importD));
-
- Assert.IsTrue(message.HasField(f("optional_nested_enum")));
- Assert.IsTrue(message.HasField(f("optional_foreign_enum")));
- Assert.IsTrue(message.HasField(f("optional_import_enum")));
-
- Assert.IsTrue(message.HasField(f("optional_string_piece")));
- Assert.IsTrue(message.HasField(f("optional_cord")));
-
- Assert.AreEqual(101, message[f("optional_int32")]);
- Assert.AreEqual(102L, message[f("optional_int64")]);
- Assert.AreEqual(103u, message[f("optional_uint32")]);
- Assert.AreEqual(104UL, message[f("optional_uint64")]);
- Assert.AreEqual(105, message[f("optional_sint32")]);
- Assert.AreEqual(106L, message[f("optional_sint64")]);
- Assert.AreEqual(107U, message[f("optional_fixed32")]);
- Assert.AreEqual(108UL, message[f("optional_fixed64")]);
- Assert.AreEqual(109, message[f("optional_sfixed32")]);
- Assert.AreEqual(110L, message[f("optional_sfixed64")]);
- Assert.AreEqual(111F, message[f("optional_float")]);
- Assert.AreEqual(112D, message[f("optional_double")]);
- Assert.AreEqual(true, message[f("optional_bool")]);
- Assert.AreEqual("115", message[f("optional_string")]);
- Assert.AreEqual(TestUtil.ToBytes("116"), message[f("optional_bytes")]);
-
- Assert.AreEqual(117, ((IMessage) message[f("optionalgroup")])[groupA]);
- Assert.AreEqual(118, ((IMessage) message[f("optional_nested_message")])[nestedB]);
- Assert.AreEqual(119, ((IMessage) message[f("optional_foreign_message")])[foreignC]);
- Assert.AreEqual(120, ((IMessage) message[f("optional_import_message")])[importD]);
-
- Assert.AreEqual(nestedBaz, message[f("optional_nested_enum")]);
- Assert.AreEqual(foreignBaz, message[f("optional_foreign_enum")]);
- Assert.AreEqual(importBaz, message[f("optional_import_enum")]);
-
- Assert.AreEqual("124", message[f("optional_string_piece")]);
- Assert.AreEqual("125", message[f("optional_cord")]);
+ Assert.True(message.HasField(f("optional_int32")));
+ Assert.True(message.HasField(f("optional_int64")));
+ Assert.True(message.HasField(f("optional_uint32")));
+ Assert.True(message.HasField(f("optional_uint64")));
+ Assert.True(message.HasField(f("optional_sint32")));
+ Assert.True(message.HasField(f("optional_sint64")));
+ Assert.True(message.HasField(f("optional_fixed32")));
+ Assert.True(message.HasField(f("optional_fixed64")));
+ Assert.True(message.HasField(f("optional_sfixed32")));
+ Assert.True(message.HasField(f("optional_sfixed64")));
+ Assert.True(message.HasField(f("optional_float")));
+ Assert.True(message.HasField(f("optional_double")));
+ Assert.True(message.HasField(f("optional_bool")));
+ Assert.True(message.HasField(f("optional_string")));
+ Assert.True(message.HasField(f("optional_bytes")));
+
+ Assert.True(message.HasField(f("optionalgroup")));
+ Assert.True(message.HasField(f("optional_nested_message")));
+ Assert.True(message.HasField(f("optional_foreign_message")));
+ Assert.True(message.HasField(f("optional_import_message")));
+
+ Assert.True(((IMessage) message[f("optionalgroup")]).HasField(groupA));
+ Assert.True(((IMessage) message[f("optional_nested_message")]).HasField(nestedB));
+ Assert.True(((IMessage) message[f("optional_foreign_message")]).HasField(foreignC));
+ Assert.True(((IMessage) message[f("optional_import_message")]).HasField(importD));
+
+ Assert.True(message.HasField(f("optional_nested_enum")));
+ Assert.True(message.HasField(f("optional_foreign_enum")));
+ Assert.True(message.HasField(f("optional_import_enum")));
+
+ Assert.True(message.HasField(f("optional_string_piece")));
+ Assert.True(message.HasField(f("optional_cord")));
+
+ Assert.Equal(101, message[f("optional_int32")]);
+ Assert.Equal(102L, message[f("optional_int64")]);
+ Assert.Equal(103u, message[f("optional_uint32")]);
+ Assert.Equal(104UL, message[f("optional_uint64")]);
+ Assert.Equal(105, message[f("optional_sint32")]);
+ Assert.Equal(106L, message[f("optional_sint64")]);
+ Assert.Equal(107U, message[f("optional_fixed32")]);
+ Assert.Equal(108UL, message[f("optional_fixed64")]);
+ Assert.Equal(109, message[f("optional_sfixed32")]);
+ Assert.Equal(110L, message[f("optional_sfixed64")]);
+ Assert.Equal(111F, message[f("optional_float")]);
+ Assert.Equal(112D, message[f("optional_double")]);
+ Assert.Equal(true, message[f("optional_bool")]);
+ Assert.Equal("115", message[f("optional_string")]);
+ Assert.Equal(TestUtil.ToBytes("116"), message[f("optional_bytes")]);
+
+ Assert.Equal(117, ((IMessage) message[f("optionalgroup")])[groupA]);
+ Assert.Equal(118, ((IMessage) message[f("optional_nested_message")])[nestedB]);
+ Assert.Equal(119, ((IMessage) message[f("optional_foreign_message")])[foreignC]);
+ Assert.Equal(120, ((IMessage) message[f("optional_import_message")])[importD]);
+
+ Assert.Equal(nestedBaz, message[f("optional_nested_enum")]);
+ Assert.Equal(foreignBaz, message[f("optional_foreign_enum")]);
+ Assert.Equal(importBaz, message[f("optional_import_enum")]);
+
+ Assert.Equal("124", message[f("optional_string_piece")]);
+ Assert.Equal("125", message[f("optional_cord")]);
// -----------------------------------------------------------------
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_int32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_int64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_uint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_uint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_fixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_fixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_float")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_double")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_bool")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_string")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_bytes")));
-
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeatedgroup")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_nested_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_import_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_import_enum")));
-
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_string_piece")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_cord")));
-
- Assert.AreEqual(201, message[f("repeated_int32"), 0]);
- Assert.AreEqual(202L, message[f("repeated_int64"), 0]);
- Assert.AreEqual(203U, message[f("repeated_uint32"), 0]);
- Assert.AreEqual(204UL, message[f("repeated_uint64"), 0]);
- Assert.AreEqual(205, message[f("repeated_sint32"), 0]);
- Assert.AreEqual(206L, message[f("repeated_sint64"), 0]);
- Assert.AreEqual(207U, message[f("repeated_fixed32"), 0]);
- Assert.AreEqual(208UL, message[f("repeated_fixed64"), 0]);
- Assert.AreEqual(209, message[f("repeated_sfixed32"), 0]);
- Assert.AreEqual(210L, message[f("repeated_sfixed64"), 0]);
- Assert.AreEqual(211F, message[f("repeated_float"), 0]);
- Assert.AreEqual(212D, message[f("repeated_double"), 0]);
- Assert.AreEqual(true, message[f("repeated_bool"), 0]);
- Assert.AreEqual("215", message[f("repeated_string"), 0]);
- Assert.AreEqual(TestUtil.ToBytes("216"), message[f("repeated_bytes"), 0]);
-
- Assert.AreEqual(217, ((IMessage) message[f("repeatedgroup"), 0])[repeatedGroupA]);
- Assert.AreEqual(218, ((IMessage) message[f("repeated_nested_message"), 0])[nestedB]);
- Assert.AreEqual(219, ((IMessage) message[f("repeated_foreign_message"), 0])[foreignC]);
- Assert.AreEqual(220, ((IMessage) message[f("repeated_import_message"), 0])[importD]);
-
- Assert.AreEqual(nestedBar, message[f("repeated_nested_enum"), 0]);
- Assert.AreEqual(foreignBar, message[f("repeated_foreign_enum"), 0]);
- Assert.AreEqual(importBar, message[f("repeated_import_enum"), 0]);
-
- Assert.AreEqual("224", message[f("repeated_string_piece"), 0]);
- Assert.AreEqual("225", message[f("repeated_cord"), 0]);
-
- Assert.AreEqual(301, message[f("repeated_int32"), 1]);
- Assert.AreEqual(302L, message[f("repeated_int64"), 1]);
- Assert.AreEqual(303U, message[f("repeated_uint32"), 1]);
- Assert.AreEqual(304UL, message[f("repeated_uint64"), 1]);
- Assert.AreEqual(305, message[f("repeated_sint32"), 1]);
- Assert.AreEqual(306L, message[f("repeated_sint64"), 1]);
- Assert.AreEqual(307U, message[f("repeated_fixed32"), 1]);
- Assert.AreEqual(308UL, message[f("repeated_fixed64"), 1]);
- Assert.AreEqual(309, message[f("repeated_sfixed32"), 1]);
- Assert.AreEqual(310L, message[f("repeated_sfixed64"), 1]);
- Assert.AreEqual(311F, message[f("repeated_float"), 1]);
- Assert.AreEqual(312D, message[f("repeated_double"), 1]);
- Assert.AreEqual(false, message[f("repeated_bool"), 1]);
- Assert.AreEqual("315", message[f("repeated_string"), 1]);
- Assert.AreEqual(TestUtil.ToBytes("316"), message[f("repeated_bytes"), 1]);
-
- Assert.AreEqual(317, ((IMessage) message[f("repeatedgroup"), 1])[repeatedGroupA]);
- Assert.AreEqual(318, ((IMessage) message[f("repeated_nested_message"), 1])[nestedB]);
- Assert.AreEqual(319, ((IMessage) message[f("repeated_foreign_message"), 1])[foreignC]);
- Assert.AreEqual(320, ((IMessage) message[f("repeated_import_message"), 1])[importD]);
-
- Assert.AreEqual(nestedBaz, message[f("repeated_nested_enum"), 1]);
- Assert.AreEqual(foreignBaz, message[f("repeated_foreign_enum"), 1]);
- Assert.AreEqual(importBaz, message[f("repeated_import_enum"), 1]);
-
- Assert.AreEqual("324", message[f("repeated_string_piece"), 1]);
- Assert.AreEqual("325", message[f("repeated_cord"), 1]);
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_int32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_int64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_uint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_uint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_fixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_fixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_float")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_double")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_bool")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_string")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_bytes")));
+
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeatedgroup")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_nested_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_import_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_import_enum")));
+
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_string_piece")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_cord")));
+
+ Assert.Equal(201, message[f("repeated_int32"), 0]);
+ Assert.Equal(202L, message[f("repeated_int64"), 0]);
+ Assert.Equal(203U, message[f("repeated_uint32"), 0]);
+ Assert.Equal(204UL, message[f("repeated_uint64"), 0]);
+ Assert.Equal(205, message[f("repeated_sint32"), 0]);
+ Assert.Equal(206L, message[f("repeated_sint64"), 0]);
+ Assert.Equal(207U, message[f("repeated_fixed32"), 0]);
+ Assert.Equal(208UL, message[f("repeated_fixed64"), 0]);
+ Assert.Equal(209, message[f("repeated_sfixed32"), 0]);
+ Assert.Equal(210L, message[f("repeated_sfixed64"), 0]);
+ Assert.Equal(211F, message[f("repeated_float"), 0]);
+ Assert.Equal(212D, message[f("repeated_double"), 0]);
+ Assert.Equal(true, message[f("repeated_bool"), 0]);
+ Assert.Equal("215", message[f("repeated_string"), 0]);
+ Assert.Equal(TestUtil.ToBytes("216"), message[f("repeated_bytes"), 0]);
+
+ Assert.Equal(217, ((IMessage) message[f("repeatedgroup"), 0])[repeatedGroupA]);
+ Assert.Equal(218, ((IMessage) message[f("repeated_nested_message"), 0])[nestedB]);
+ Assert.Equal(219, ((IMessage) message[f("repeated_foreign_message"), 0])[foreignC]);
+ Assert.Equal(220, ((IMessage) message[f("repeated_import_message"), 0])[importD]);
+
+ Assert.Equal(nestedBar, message[f("repeated_nested_enum"), 0]);
+ Assert.Equal(foreignBar, message[f("repeated_foreign_enum"), 0]);
+ Assert.Equal(importBar, message[f("repeated_import_enum"), 0]);
+
+ Assert.Equal("224", message[f("repeated_string_piece"), 0]);
+ Assert.Equal("225", message[f("repeated_cord"), 0]);
+
+ Assert.Equal(301, message[f("repeated_int32"), 1]);
+ Assert.Equal(302L, message[f("repeated_int64"), 1]);
+ Assert.Equal(303U, message[f("repeated_uint32"), 1]);
+ Assert.Equal(304UL, message[f("repeated_uint64"), 1]);
+ Assert.Equal(305, message[f("repeated_sint32"), 1]);
+ Assert.Equal(306L, message[f("repeated_sint64"), 1]);
+ Assert.Equal(307U, message[f("repeated_fixed32"), 1]);
+ Assert.Equal(308UL, message[f("repeated_fixed64"), 1]);
+ Assert.Equal(309, message[f("repeated_sfixed32"), 1]);
+ Assert.Equal(310L, message[f("repeated_sfixed64"), 1]);
+ Assert.Equal(311F, message[f("repeated_float"), 1]);
+ Assert.Equal(312D, message[f("repeated_double"), 1]);
+ Assert.Equal(false, message[f("repeated_bool"), 1]);
+ Assert.Equal("315", message[f("repeated_string"), 1]);
+ Assert.Equal(TestUtil.ToBytes("316"), message[f("repeated_bytes"), 1]);
+
+ Assert.Equal(317, ((IMessage) message[f("repeatedgroup"), 1])[repeatedGroupA]);
+ Assert.Equal(318, ((IMessage) message[f("repeated_nested_message"), 1])[nestedB]);
+ Assert.Equal(319, ((IMessage) message[f("repeated_foreign_message"), 1])[foreignC]);
+ Assert.Equal(320, ((IMessage) message[f("repeated_import_message"), 1])[importD]);
+
+ Assert.Equal(nestedBaz, message[f("repeated_nested_enum"), 1]);
+ Assert.Equal(foreignBaz, message[f("repeated_foreign_enum"), 1]);
+ Assert.Equal(importBaz, message[f("repeated_import_enum"), 1]);
+
+ Assert.Equal("324", message[f("repeated_string_piece"), 1]);
+ Assert.Equal("325", message[f("repeated_cord"), 1]);
// -----------------------------------------------------------------
- Assert.IsTrue(message.HasField(f("default_int32")));
- Assert.IsTrue(message.HasField(f("default_int64")));
- Assert.IsTrue(message.HasField(f("default_uint32")));
- Assert.IsTrue(message.HasField(f("default_uint64")));
- Assert.IsTrue(message.HasField(f("default_sint32")));
- Assert.IsTrue(message.HasField(f("default_sint64")));
- Assert.IsTrue(message.HasField(f("default_fixed32")));
- Assert.IsTrue(message.HasField(f("default_fixed64")));
- Assert.IsTrue(message.HasField(f("default_sfixed32")));
- Assert.IsTrue(message.HasField(f("default_sfixed64")));
- Assert.IsTrue(message.HasField(f("default_float")));
- Assert.IsTrue(message.HasField(f("default_double")));
- Assert.IsTrue(message.HasField(f("default_bool")));
- Assert.IsTrue(message.HasField(f("default_string")));
- Assert.IsTrue(message.HasField(f("default_bytes")));
-
- Assert.IsTrue(message.HasField(f("default_nested_enum")));
- Assert.IsTrue(message.HasField(f("default_foreign_enum")));
- Assert.IsTrue(message.HasField(f("default_import_enum")));
-
- Assert.IsTrue(message.HasField(f("default_string_piece")));
- Assert.IsTrue(message.HasField(f("default_cord")));
-
- Assert.AreEqual(401, message[f("default_int32")]);
- Assert.AreEqual(402L, message[f("default_int64")]);
- Assert.AreEqual(403U, message[f("default_uint32")]);
- Assert.AreEqual(404UL, message[f("default_uint64")]);
- Assert.AreEqual(405, message[f("default_sint32")]);
- Assert.AreEqual(406L, message[f("default_sint64")]);
- Assert.AreEqual(407U, message[f("default_fixed32")]);
- Assert.AreEqual(408UL, message[f("default_fixed64")]);
- Assert.AreEqual(409, message[f("default_sfixed32")]);
- Assert.AreEqual(410L, message[f("default_sfixed64")]);
- Assert.AreEqual(411F, message[f("default_float")]);
- Assert.AreEqual(412D, message[f("default_double")]);
- Assert.AreEqual(false, message[f("default_bool")]);
- Assert.AreEqual("415", message[f("default_string")]);
- Assert.AreEqual(TestUtil.ToBytes("416"), message[f("default_bytes")]);
-
- Assert.AreEqual(nestedFoo, message[f("default_nested_enum")]);
- Assert.AreEqual(foreignFoo, message[f("default_foreign_enum")]);
- Assert.AreEqual(importFoo, message[f("default_import_enum")]);
-
- Assert.AreEqual("424", message[f("default_string_piece")]);
- Assert.AreEqual("425", message[f("default_cord")]);
+ Assert.True(message.HasField(f("default_int32")));
+ Assert.True(message.HasField(f("default_int64")));
+ Assert.True(message.HasField(f("default_uint32")));
+ Assert.True(message.HasField(f("default_uint64")));
+ Assert.True(message.HasField(f("default_sint32")));
+ Assert.True(message.HasField(f("default_sint64")));
+ Assert.True(message.HasField(f("default_fixed32")));
+ Assert.True(message.HasField(f("default_fixed64")));
+ Assert.True(message.HasField(f("default_sfixed32")));
+ Assert.True(message.HasField(f("default_sfixed64")));
+ Assert.True(message.HasField(f("default_float")));
+ Assert.True(message.HasField(f("default_double")));
+ Assert.True(message.HasField(f("default_bool")));
+ Assert.True(message.HasField(f("default_string")));
+ Assert.True(message.HasField(f("default_bytes")));
+
+ Assert.True(message.HasField(f("default_nested_enum")));
+ Assert.True(message.HasField(f("default_foreign_enum")));
+ Assert.True(message.HasField(f("default_import_enum")));
+
+ Assert.True(message.HasField(f("default_string_piece")));
+ Assert.True(message.HasField(f("default_cord")));
+
+ Assert.Equal(401, message[f("default_int32")]);
+ Assert.Equal(402L, message[f("default_int64")]);
+ Assert.Equal(403U, message[f("default_uint32")]);
+ Assert.Equal(404UL, message[f("default_uint64")]);
+ Assert.Equal(405, message[f("default_sint32")]);
+ Assert.Equal(406L, message[f("default_sint64")]);
+ Assert.Equal(407U, message[f("default_fixed32")]);
+ Assert.Equal(408UL, message[f("default_fixed64")]);
+ Assert.Equal(409, message[f("default_sfixed32")]);
+ Assert.Equal(410L, message[f("default_sfixed64")]);
+ Assert.Equal(411F, message[f("default_float")]);
+ Assert.Equal(412D, message[f("default_double")]);
+ Assert.Equal(false, message[f("default_bool")]);
+ Assert.Equal("415", message[f("default_string")]);
+ Assert.Equal(TestUtil.ToBytes("416"), message[f("default_bytes")]);
+
+ Assert.Equal(nestedFoo, message[f("default_nested_enum")]);
+ Assert.Equal(foreignFoo, message[f("default_foreign_enum")]);
+ Assert.Equal(importFoo, message[f("default_import_enum")]);
+
+ Assert.Equal("424", message[f("default_string_piece")]);
+ Assert.Equal("425", message[f("default_cord")]);
}
/// <summary>
@@ -651,148 +651,148 @@ namespace Google.ProtocolBuffers public void AssertClearViaReflection(IMessage message)
{
// has_blah() should initially be false for all optional fields.
- Assert.IsFalse(message.HasField(f("optional_int32")));
- Assert.IsFalse(message.HasField(f("optional_int64")));
- Assert.IsFalse(message.HasField(f("optional_uint32")));
- Assert.IsFalse(message.HasField(f("optional_uint64")));
- Assert.IsFalse(message.HasField(f("optional_sint32")));
- Assert.IsFalse(message.HasField(f("optional_sint64")));
- Assert.IsFalse(message.HasField(f("optional_fixed32")));
- Assert.IsFalse(message.HasField(f("optional_fixed64")));
- Assert.IsFalse(message.HasField(f("optional_sfixed32")));
- Assert.IsFalse(message.HasField(f("optional_sfixed64")));
- Assert.IsFalse(message.HasField(f("optional_float")));
- Assert.IsFalse(message.HasField(f("optional_double")));
- Assert.IsFalse(message.HasField(f("optional_bool")));
- Assert.IsFalse(message.HasField(f("optional_string")));
- Assert.IsFalse(message.HasField(f("optional_bytes")));
-
- Assert.IsFalse(message.HasField(f("optionalgroup")));
- Assert.IsFalse(message.HasField(f("optional_nested_message")));
- Assert.IsFalse(message.HasField(f("optional_foreign_message")));
- Assert.IsFalse(message.HasField(f("optional_import_message")));
-
- Assert.IsFalse(message.HasField(f("optional_nested_enum")));
- Assert.IsFalse(message.HasField(f("optional_foreign_enum")));
- Assert.IsFalse(message.HasField(f("optional_import_enum")));
-
- Assert.IsFalse(message.HasField(f("optional_string_piece")));
- Assert.IsFalse(message.HasField(f("optional_cord")));
+ Assert.False(message.HasField(f("optional_int32")));
+ Assert.False(message.HasField(f("optional_int64")));
+ Assert.False(message.HasField(f("optional_uint32")));
+ Assert.False(message.HasField(f("optional_uint64")));
+ Assert.False(message.HasField(f("optional_sint32")));
+ Assert.False(message.HasField(f("optional_sint64")));
+ Assert.False(message.HasField(f("optional_fixed32")));
+ Assert.False(message.HasField(f("optional_fixed64")));
+ Assert.False(message.HasField(f("optional_sfixed32")));
+ Assert.False(message.HasField(f("optional_sfixed64")));
+ Assert.False(message.HasField(f("optional_float")));
+ Assert.False(message.HasField(f("optional_double")));
+ Assert.False(message.HasField(f("optional_bool")));
+ Assert.False(message.HasField(f("optional_string")));
+ Assert.False(message.HasField(f("optional_bytes")));
+
+ Assert.False(message.HasField(f("optionalgroup")));
+ Assert.False(message.HasField(f("optional_nested_message")));
+ Assert.False(message.HasField(f("optional_foreign_message")));
+ Assert.False(message.HasField(f("optional_import_message")));
+
+ Assert.False(message.HasField(f("optional_nested_enum")));
+ Assert.False(message.HasField(f("optional_foreign_enum")));
+ Assert.False(message.HasField(f("optional_import_enum")));
+
+ Assert.False(message.HasField(f("optional_string_piece")));
+ Assert.False(message.HasField(f("optional_cord")));
// Optional fields without defaults are set to zero or something like it.
- Assert.AreEqual(0, message[f("optional_int32")]);
- Assert.AreEqual(0L, message[f("optional_int64")]);
- Assert.AreEqual(0U, message[f("optional_uint32")]);
- Assert.AreEqual(0UL, message[f("optional_uint64")]);
- Assert.AreEqual(0, message[f("optional_sint32")]);
- Assert.AreEqual(0L, message[f("optional_sint64")]);
- Assert.AreEqual(0U, message[f("optional_fixed32")]);
- Assert.AreEqual(0UL, message[f("optional_fixed64")]);
- Assert.AreEqual(0, message[f("optional_sfixed32")]);
- Assert.AreEqual(0L, message[f("optional_sfixed64")]);
- Assert.AreEqual(0F, message[f("optional_float")]);
- Assert.AreEqual(0D, message[f("optional_double")]);
- Assert.AreEqual(false, message[f("optional_bool")]);
- Assert.AreEqual("", message[f("optional_string")]);
- Assert.AreEqual(ByteString.Empty, message[f("optional_bytes")]);
+ Assert.Equal(0, message[f("optional_int32")]);
+ Assert.Equal(0L, message[f("optional_int64")]);
+ Assert.Equal(0U, message[f("optional_uint32")]);
+ Assert.Equal(0UL, message[f("optional_uint64")]);
+ Assert.Equal(0, message[f("optional_sint32")]);
+ Assert.Equal(0L, message[f("optional_sint64")]);
+ Assert.Equal(0U, message[f("optional_fixed32")]);
+ Assert.Equal(0UL, message[f("optional_fixed64")]);
+ Assert.Equal(0, message[f("optional_sfixed32")]);
+ Assert.Equal(0L, message[f("optional_sfixed64")]);
+ Assert.Equal(0F, message[f("optional_float")]);
+ Assert.Equal(0D, message[f("optional_double")]);
+ Assert.Equal(false, message[f("optional_bool")]);
+ Assert.Equal("", message[f("optional_string")]);
+ Assert.Equal(ByteString.Empty, message[f("optional_bytes")]);
// Embedded messages should also be clear.
- Assert.IsFalse(((IMessage) message[f("optionalgroup")]).HasField(groupA));
- Assert.IsFalse(((IMessage) message[f("optional_nested_message")])
+ Assert.False(((IMessage) message[f("optionalgroup")]).HasField(groupA));
+ Assert.False(((IMessage) message[f("optional_nested_message")])
.HasField(nestedB));
- Assert.IsFalse(((IMessage) message[f("optional_foreign_message")])
+ Assert.False(((IMessage) message[f("optional_foreign_message")])
.HasField(foreignC));
- Assert.IsFalse(((IMessage) message[f("optional_import_message")])
+ Assert.False(((IMessage) message[f("optional_import_message")])
.HasField(importD));
- Assert.AreEqual(0, ((IMessage) message[f("optionalgroup")])[groupA]);
- Assert.AreEqual(0, ((IMessage) message[f("optional_nested_message")])[nestedB]);
- Assert.AreEqual(0, ((IMessage) message[f("optional_foreign_message")])[foreignC]);
- Assert.AreEqual(0, ((IMessage) message[f("optional_import_message")])[importD]);
+ Assert.Equal(0, ((IMessage) message[f("optionalgroup")])[groupA]);
+ Assert.Equal(0, ((IMessage) message[f("optional_nested_message")])[nestedB]);
+ Assert.Equal(0, ((IMessage) message[f("optional_foreign_message")])[foreignC]);
+ Assert.Equal(0, ((IMessage) message[f("optional_import_message")])[importD]);
// Enums without defaults are set to the first value in the enum.
- Assert.AreEqual(nestedFoo, message[f("optional_nested_enum")]);
- Assert.AreEqual(foreignFoo, message[f("optional_foreign_enum")]);
- Assert.AreEqual(importFoo, message[f("optional_import_enum")]);
+ Assert.Equal(nestedFoo, message[f("optional_nested_enum")]);
+ Assert.Equal(foreignFoo, message[f("optional_foreign_enum")]);
+ Assert.Equal(importFoo, message[f("optional_import_enum")]);
- Assert.AreEqual("", message[f("optional_string_piece")]);
- Assert.AreEqual("", message[f("optional_cord")]);
+ Assert.Equal("", message[f("optional_string_piece")]);
+ Assert.Equal("", message[f("optional_cord")]);
// Repeated fields are empty.
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_int32")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_int64")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_uint32")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_uint64")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_sint32")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_sint64")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_fixed32")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_fixed64")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_float")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_double")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_bool")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_string")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_bytes")));
-
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeatedgroup")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_nested_message")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_import_message")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_import_enum")));
-
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_string_piece")));
- Assert.AreEqual(0, message.GetRepeatedFieldCount(f("repeated_cord")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_int32")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_int64")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_uint32")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_uint64")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_sint32")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_sint64")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_fixed32")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_fixed64")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_float")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_double")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_bool")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_string")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_bytes")));
+
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeatedgroup")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_nested_message")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_import_message")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_import_enum")));
+
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_string_piece")));
+ Assert.Equal(0, message.GetRepeatedFieldCount(f("repeated_cord")));
// has_blah() should also be false for all default fields.
- Assert.IsFalse(message.HasField(f("default_int32")));
- Assert.IsFalse(message.HasField(f("default_int64")));
- Assert.IsFalse(message.HasField(f("default_uint32")));
- Assert.IsFalse(message.HasField(f("default_uint64")));
- Assert.IsFalse(message.HasField(f("default_sint32")));
- Assert.IsFalse(message.HasField(f("default_sint64")));
- Assert.IsFalse(message.HasField(f("default_fixed32")));
- Assert.IsFalse(message.HasField(f("default_fixed64")));
- Assert.IsFalse(message.HasField(f("default_sfixed32")));
- Assert.IsFalse(message.HasField(f("default_sfixed64")));
- Assert.IsFalse(message.HasField(f("default_float")));
- Assert.IsFalse(message.HasField(f("default_double")));
- Assert.IsFalse(message.HasField(f("default_bool")));
- Assert.IsFalse(message.HasField(f("default_string")));
- Assert.IsFalse(message.HasField(f("default_bytes")));
-
- Assert.IsFalse(message.HasField(f("default_nested_enum")));
- Assert.IsFalse(message.HasField(f("default_foreign_enum")));
- Assert.IsFalse(message.HasField(f("default_import_enum")));
-
- Assert.IsFalse(message.HasField(f("default_string_piece")));
- Assert.IsFalse(message.HasField(f("default_cord")));
+ Assert.False(message.HasField(f("default_int32")));
+ Assert.False(message.HasField(f("default_int64")));
+ Assert.False(message.HasField(f("default_uint32")));
+ Assert.False(message.HasField(f("default_uint64")));
+ Assert.False(message.HasField(f("default_sint32")));
+ Assert.False(message.HasField(f("default_sint64")));
+ Assert.False(message.HasField(f("default_fixed32")));
+ Assert.False(message.HasField(f("default_fixed64")));
+ Assert.False(message.HasField(f("default_sfixed32")));
+ Assert.False(message.HasField(f("default_sfixed64")));
+ Assert.False(message.HasField(f("default_float")));
+ Assert.False(message.HasField(f("default_double")));
+ Assert.False(message.HasField(f("default_bool")));
+ Assert.False(message.HasField(f("default_string")));
+ Assert.False(message.HasField(f("default_bytes")));
+
+ Assert.False(message.HasField(f("default_nested_enum")));
+ Assert.False(message.HasField(f("default_foreign_enum")));
+ Assert.False(message.HasField(f("default_import_enum")));
+
+ Assert.False(message.HasField(f("default_string_piece")));
+ Assert.False(message.HasField(f("default_cord")));
// Fields with defaults have their default values (duh).
- Assert.AreEqual(41, message[f("default_int32")]);
- Assert.AreEqual(42L, message[f("default_int64")]);
- Assert.AreEqual(43U, message[f("default_uint32")]);
- Assert.AreEqual(44UL, message[f("default_uint64")]);
- Assert.AreEqual(-45, message[f("default_sint32")]);
- Assert.AreEqual(46L, message[f("default_sint64")]);
- Assert.AreEqual(47U, message[f("default_fixed32")]);
- Assert.AreEqual(48UL, message[f("default_fixed64")]);
- Assert.AreEqual(49, message[f("default_sfixed32")]);
- Assert.AreEqual(-50L, message[f("default_sfixed64")]);
- Assert.AreEqual(51.5F, message[f("default_float")]);
- Assert.AreEqual(52e3D, message[f("default_double")]);
- Assert.AreEqual(true, message[f("default_bool")]);
- Assert.AreEqual("hello", message[f("default_string")]);
- Assert.AreEqual(TestUtil.ToBytes("world"), message[f("default_bytes")]);
-
- Assert.AreEqual(nestedBar, message[f("default_nested_enum")]);
- Assert.AreEqual(foreignBar, message[f("default_foreign_enum")]);
- Assert.AreEqual(importBar, message[f("default_import_enum")]);
-
- Assert.AreEqual("abc", message[f("default_string_piece")]);
- Assert.AreEqual("123", message[f("default_cord")]);
+ Assert.Equal(41, message[f("default_int32")]);
+ Assert.Equal(42L, message[f("default_int64")]);
+ Assert.Equal(43U, message[f("default_uint32")]);
+ Assert.Equal(44UL, message[f("default_uint64")]);
+ Assert.Equal(-45, message[f("default_sint32")]);
+ Assert.Equal(46L, message[f("default_sint64")]);
+ Assert.Equal(47U, message[f("default_fixed32")]);
+ Assert.Equal(48UL, message[f("default_fixed64")]);
+ Assert.Equal(49, message[f("default_sfixed32")]);
+ Assert.Equal(-50L, message[f("default_sfixed64")]);
+ Assert.Equal(51.5F, message[f("default_float")]);
+ Assert.Equal(52e3D, message[f("default_double")]);
+ Assert.Equal(true, message[f("default_bool")]);
+ Assert.Equal("hello", message[f("default_string")]);
+ Assert.Equal(TestUtil.ToBytes("world"), message[f("default_bytes")]);
+
+ Assert.Equal(nestedBar, message[f("default_nested_enum")]);
+ Assert.Equal(foreignBar, message[f("default_foreign_enum")]);
+ Assert.Equal(importBar, message[f("default_import_enum")]);
+
+ Assert.Equal("abc", message[f("default_string_piece")]);
+ Assert.Equal("123", message[f("default_cord")]);
}
// ---------------------------------------------------------------
@@ -802,88 +802,88 @@ namespace Google.ProtocolBuffers // ModifyRepeatedFields only sets the second repeated element of each
// field. In addition to verifying this, we also verify that the first
// element and size were *not* modified.
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_int32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_int64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_uint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_uint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_fixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_fixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_float")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_double")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_bool")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_string")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_bytes")));
-
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeatedgroup")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_nested_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_import_message")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_import_enum")));
-
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_string_piece")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("repeated_cord")));
-
- Assert.AreEqual(201, message[f("repeated_int32"), 0]);
- Assert.AreEqual(202L, message[f("repeated_int64"), 0]);
- Assert.AreEqual(203U, message[f("repeated_uint32"), 0]);
- Assert.AreEqual(204UL, message[f("repeated_uint64"), 0]);
- Assert.AreEqual(205, message[f("repeated_sint32"), 0]);
- Assert.AreEqual(206L, message[f("repeated_sint64"), 0]);
- Assert.AreEqual(207U, message[f("repeated_fixed32"), 0]);
- Assert.AreEqual(208UL, message[f("repeated_fixed64"), 0]);
- Assert.AreEqual(209, message[f("repeated_sfixed32"), 0]);
- Assert.AreEqual(210L, message[f("repeated_sfixed64"), 0]);
- Assert.AreEqual(211F, message[f("repeated_float"), 0]);
- Assert.AreEqual(212D, message[f("repeated_double"), 0]);
- Assert.AreEqual(true, message[f("repeated_bool"), 0]);
- Assert.AreEqual("215", message[f("repeated_string"), 0]);
- Assert.AreEqual(TestUtil.ToBytes("216"), message[f("repeated_bytes"), 0]);
-
- Assert.AreEqual(217, ((IMessage) message[f("repeatedgroup"), 0])[repeatedGroupA]);
- Assert.AreEqual(218, ((IMessage) message[f("repeated_nested_message"), 0])[nestedB]);
- Assert.AreEqual(219, ((IMessage) message[f("repeated_foreign_message"), 0])[foreignC]);
- Assert.AreEqual(220, ((IMessage) message[f("repeated_import_message"), 0])[importD]);
-
- Assert.AreEqual(nestedBar, message[f("repeated_nested_enum"), 0]);
- Assert.AreEqual(foreignBar, message[f("repeated_foreign_enum"), 0]);
- Assert.AreEqual(importBar, message[f("repeated_import_enum"), 0]);
-
- Assert.AreEqual("224", message[f("repeated_string_piece"), 0]);
- Assert.AreEqual("225", message[f("repeated_cord"), 0]);
-
- Assert.AreEqual(501, message[f("repeated_int32"), 1]);
- Assert.AreEqual(502L, message[f("repeated_int64"), 1]);
- Assert.AreEqual(503U, message[f("repeated_uint32"), 1]);
- Assert.AreEqual(504UL, message[f("repeated_uint64"), 1]);
- Assert.AreEqual(505, message[f("repeated_sint32"), 1]);
- Assert.AreEqual(506L, message[f("repeated_sint64"), 1]);
- Assert.AreEqual(507U, message[f("repeated_fixed32"), 1]);
- Assert.AreEqual(508UL, message[f("repeated_fixed64"), 1]);
- Assert.AreEqual(509, message[f("repeated_sfixed32"), 1]);
- Assert.AreEqual(510L, message[f("repeated_sfixed64"), 1]);
- Assert.AreEqual(511F, message[f("repeated_float"), 1]);
- Assert.AreEqual(512D, message[f("repeated_double"), 1]);
- Assert.AreEqual(true, message[f("repeated_bool"), 1]);
- Assert.AreEqual("515", message[f("repeated_string"), 1]);
- Assert.AreEqual(TestUtil.ToBytes("516"), message[f("repeated_bytes"), 1]);
-
- Assert.AreEqual(517, ((IMessage) message[f("repeatedgroup"), 1])[repeatedGroupA]);
- Assert.AreEqual(518, ((IMessage) message[f("repeated_nested_message"), 1])[nestedB]);
- Assert.AreEqual(519, ((IMessage) message[f("repeated_foreign_message"), 1])[foreignC]);
- Assert.AreEqual(520, ((IMessage) message[f("repeated_import_message"), 1])[importD]);
-
- Assert.AreEqual(nestedFoo, message[f("repeated_nested_enum"), 1]);
- Assert.AreEqual(foreignFoo, message[f("repeated_foreign_enum"), 1]);
- Assert.AreEqual(importFoo, message[f("repeated_import_enum"), 1]);
-
- Assert.AreEqual("524", message[f("repeated_string_piece"), 1]);
- Assert.AreEqual("525", message[f("repeated_cord"), 1]);
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_int32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_int64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_uint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_uint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_fixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_fixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sfixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_sfixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_float")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_double")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_bool")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_string")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_bytes")));
+
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeatedgroup")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_nested_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_foreign_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_import_message")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_nested_enum")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_foreign_enum")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_import_enum")));
+
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_string_piece")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("repeated_cord")));
+
+ Assert.Equal(201, message[f("repeated_int32"), 0]);
+ Assert.Equal(202L, message[f("repeated_int64"), 0]);
+ Assert.Equal(203U, message[f("repeated_uint32"), 0]);
+ Assert.Equal(204UL, message[f("repeated_uint64"), 0]);
+ Assert.Equal(205, message[f("repeated_sint32"), 0]);
+ Assert.Equal(206L, message[f("repeated_sint64"), 0]);
+ Assert.Equal(207U, message[f("repeated_fixed32"), 0]);
+ Assert.Equal(208UL, message[f("repeated_fixed64"), 0]);
+ Assert.Equal(209, message[f("repeated_sfixed32"), 0]);
+ Assert.Equal(210L, message[f("repeated_sfixed64"), 0]);
+ Assert.Equal(211F, message[f("repeated_float"), 0]);
+ Assert.Equal(212D, message[f("repeated_double"), 0]);
+ Assert.Equal(true, message[f("repeated_bool"), 0]);
+ Assert.Equal("215", message[f("repeated_string"), 0]);
+ Assert.Equal(TestUtil.ToBytes("216"), message[f("repeated_bytes"), 0]);
+
+ Assert.Equal(217, ((IMessage) message[f("repeatedgroup"), 0])[repeatedGroupA]);
+ Assert.Equal(218, ((IMessage) message[f("repeated_nested_message"), 0])[nestedB]);
+ Assert.Equal(219, ((IMessage) message[f("repeated_foreign_message"), 0])[foreignC]);
+ Assert.Equal(220, ((IMessage) message[f("repeated_import_message"), 0])[importD]);
+
+ Assert.Equal(nestedBar, message[f("repeated_nested_enum"), 0]);
+ Assert.Equal(foreignBar, message[f("repeated_foreign_enum"), 0]);
+ Assert.Equal(importBar, message[f("repeated_import_enum"), 0]);
+
+ Assert.Equal("224", message[f("repeated_string_piece"), 0]);
+ Assert.Equal("225", message[f("repeated_cord"), 0]);
+
+ Assert.Equal(501, message[f("repeated_int32"), 1]);
+ Assert.Equal(502L, message[f("repeated_int64"), 1]);
+ Assert.Equal(503U, message[f("repeated_uint32"), 1]);
+ Assert.Equal(504UL, message[f("repeated_uint64"), 1]);
+ Assert.Equal(505, message[f("repeated_sint32"), 1]);
+ Assert.Equal(506L, message[f("repeated_sint64"), 1]);
+ Assert.Equal(507U, message[f("repeated_fixed32"), 1]);
+ Assert.Equal(508UL, message[f("repeated_fixed64"), 1]);
+ Assert.Equal(509, message[f("repeated_sfixed32"), 1]);
+ Assert.Equal(510L, message[f("repeated_sfixed64"), 1]);
+ Assert.Equal(511F, message[f("repeated_float"), 1]);
+ Assert.Equal(512D, message[f("repeated_double"), 1]);
+ Assert.Equal(true, message[f("repeated_bool"), 1]);
+ Assert.Equal("515", message[f("repeated_string"), 1]);
+ Assert.Equal(TestUtil.ToBytes("516"), message[f("repeated_bytes"), 1]);
+
+ Assert.Equal(517, ((IMessage) message[f("repeatedgroup"), 1])[repeatedGroupA]);
+ Assert.Equal(518, ((IMessage) message[f("repeated_nested_message"), 1])[nestedB]);
+ Assert.Equal(519, ((IMessage) message[f("repeated_foreign_message"), 1])[foreignC]);
+ Assert.Equal(520, ((IMessage) message[f("repeated_import_message"), 1])[importD]);
+
+ Assert.Equal(nestedFoo, message[f("repeated_nested_enum"), 1]);
+ Assert.Equal(foreignFoo, message[f("repeated_foreign_enum"), 1]);
+ Assert.Equal(importFoo, message[f("repeated_import_enum"), 1]);
+
+ Assert.Equal("524", message[f("repeated_string_piece"), 1]);
+ Assert.Equal("525", message[f("repeated_cord"), 1]);
}
/// <summary>
@@ -892,15 +892,15 @@ namespace Google.ProtocolBuffers /// </summary>
public void AssertReflectionSettersRejectNull(IBuilder builder)
{
- TestUtil.AssertArgumentNullException(() => builder[f("optional_string")] = null);
- TestUtil.AssertArgumentNullException(() => builder[f("optional_bytes")] = null);
- TestUtil.AssertArgumentNullException(() => builder[f("optional_nested_enum")] = null);
- TestUtil.AssertArgumentNullException(() => builder[f("optional_nested_message")] = null);
- TestUtil.AssertArgumentNullException(() => builder[f("optional_nested_message")] = null);
- TestUtil.AssertArgumentNullException(() => builder.WeakAddRepeatedField(f("repeated_string"), null));
- TestUtil.AssertArgumentNullException(() => builder.WeakAddRepeatedField(f("repeated_bytes"), null));
- TestUtil.AssertArgumentNullException(() => builder.WeakAddRepeatedField(f("repeated_nested_enum"), null));
- TestUtil.AssertArgumentNullException(() => builder.WeakAddRepeatedField(f("repeated_nested_message"), null));
+ Assert.Throws<ArgumentNullException>(() => builder[f("optional_string")] = null);
+ Assert.Throws<ArgumentNullException>(() => builder[f("optional_bytes")] = null);
+ Assert.Throws<ArgumentNullException>(() => builder[f("optional_nested_enum")] = null);
+ Assert.Throws<ArgumentNullException>(() => builder[f("optional_nested_message")] = null);
+ Assert.Throws<ArgumentNullException>(() => builder[f("optional_nested_message")] = null);
+ Assert.Throws<ArgumentNullException>(() => builder.WeakAddRepeatedField(f("repeated_string"), null));
+ Assert.Throws<ArgumentNullException>(() => builder.WeakAddRepeatedField(f("repeated_bytes"), null));
+ Assert.Throws<ArgumentNullException>(() => builder.WeakAddRepeatedField(f("repeated_nested_enum"), null));
+ Assert.Throws<ArgumentNullException>(() => builder.WeakAddRepeatedField(f("repeated_nested_message"), null));
}
/// <summary>
@@ -910,14 +910,14 @@ namespace Google.ProtocolBuffers public void AssertReflectionRepeatedSettersRejectNull(IBuilder builder)
{
builder.WeakAddRepeatedField(f("repeated_string"), "one");
- TestUtil.AssertArgumentNullException(() => builder.SetRepeatedField(f("repeated_string"), 0, null));
+ Assert.Throws<ArgumentNullException>(() => builder.SetRepeatedField(f("repeated_string"), 0, null));
builder.WeakAddRepeatedField(f("repeated_bytes"), TestUtil.ToBytes("one"));
- TestUtil.AssertArgumentNullException(() => builder.SetRepeatedField(f("repeated_bytes"), 0, null));
+ Assert.Throws<ArgumentNullException>(() => builder.SetRepeatedField(f("repeated_bytes"), 0, null));
builder.WeakAddRepeatedField(f("repeated_nested_enum"), nestedBaz);
- TestUtil.AssertArgumentNullException(() => builder.SetRepeatedField(f("repeated_nested_enum"), 0, null));
+ Assert.Throws<ArgumentNullException>(() => builder.SetRepeatedField(f("repeated_nested_enum"), 0, null));
builder.WeakAddRepeatedField(f("repeated_nested_message"),
new TestAllTypes.Types.NestedMessage.Builder {Bb = 218}.Build());
- TestUtil.AssertArgumentNullException(() => builder.SetRepeatedField(f("repeated_nested_message"), 0, null));
+ Assert.Throws<ArgumentNullException>(() => builder.SetRepeatedField(f("repeated_nested_message"), 0, null));
}
public void SetPackedFieldsViaReflection(IBuilder message)
@@ -955,50 +955,50 @@ namespace Google.ProtocolBuffers public void AssertPackedFieldsSetViaReflection(IMessage message)
{
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_int32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_int64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_uint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_uint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_sint32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_sint64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_fixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_fixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_sfixed32")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_sfixed64")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_float")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_double")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_bool")));
- Assert.AreEqual(2, message.GetRepeatedFieldCount(f("packed_enum")));
-
- Assert.AreEqual(601, message[f("packed_int32"), 0]);
- Assert.AreEqual(602L, message[f("packed_int64"), 0]);
- Assert.AreEqual(603u, message[f("packed_uint32"), 0]);
- Assert.AreEqual(604uL, message[f("packed_uint64"), 0]);
- Assert.AreEqual(605, message[f("packed_sint32"), 0]);
- Assert.AreEqual(606L, message[f("packed_sint64"), 0]);
- Assert.AreEqual(607u, message[f("packed_fixed32"), 0]);
- Assert.AreEqual(608uL, message[f("packed_fixed64"), 0]);
- Assert.AreEqual(609, message[f("packed_sfixed32"), 0]);
- Assert.AreEqual(610L, message[f("packed_sfixed64"), 0]);
- Assert.AreEqual(611F, message[f("packed_float"), 0]);
- Assert.AreEqual(612D, message[f("packed_double"), 0]);
- Assert.AreEqual(true, message[f("packed_bool"), 0]);
- Assert.AreEqual(foreignBar, message[f("packed_enum"), 0]);
-
- Assert.AreEqual(701, message[f("packed_int32"), 1]);
- Assert.AreEqual(702L, message[f("packed_int64"), 1]);
- Assert.AreEqual(703u, message[f("packed_uint32"), 1]);
- Assert.AreEqual(704uL, message[f("packed_uint64"), 1]);
- Assert.AreEqual(705, message[f("packed_sint32"), 1]);
- Assert.AreEqual(706L, message[f("packed_sint64"), 1]);
- Assert.AreEqual(707u, message[f("packed_fixed32"), 1]);
- Assert.AreEqual(708uL, message[f("packed_fixed64"), 1]);
- Assert.AreEqual(709, message[f("packed_sfixed32"), 1]);
- Assert.AreEqual(710L, message[f("packed_sfixed64"), 1]);
- Assert.AreEqual(711F, message[f("packed_float"), 1]);
- Assert.AreEqual(712D, message[f("packed_double"), 1]);
- Assert.AreEqual(false, message[f("packed_bool"), 1]);
- Assert.AreEqual(foreignBaz, message[f("packed_enum"), 1]);
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_int32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_int64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_uint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_uint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_sint32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_sint64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_fixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_fixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_sfixed32")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_sfixed64")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_float")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_double")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_bool")));
+ Assert.Equal(2, message.GetRepeatedFieldCount(f("packed_enum")));
+
+ Assert.Equal(601, message[f("packed_int32"), 0]);
+ Assert.Equal(602L, message[f("packed_int64"), 0]);
+ Assert.Equal(603u, message[f("packed_uint32"), 0]);
+ Assert.Equal(604uL, message[f("packed_uint64"), 0]);
+ Assert.Equal(605, message[f("packed_sint32"), 0]);
+ Assert.Equal(606L, message[f("packed_sint64"), 0]);
+ Assert.Equal(607u, message[f("packed_fixed32"), 0]);
+ Assert.Equal(608uL, message[f("packed_fixed64"), 0]);
+ Assert.Equal(609, message[f("packed_sfixed32"), 0]);
+ Assert.Equal(610L, message[f("packed_sfixed64"), 0]);
+ Assert.Equal(611F, message[f("packed_float"), 0]);
+ Assert.Equal(612D, message[f("packed_double"), 0]);
+ Assert.Equal(true, message[f("packed_bool"), 0]);
+ Assert.Equal(foreignBar, message[f("packed_enum"), 0]);
+
+ Assert.Equal(701, message[f("packed_int32"), 1]);
+ Assert.Equal(702L, message[f("packed_int64"), 1]);
+ Assert.Equal(703u, message[f("packed_uint32"), 1]);
+ Assert.Equal(704uL, message[f("packed_uint64"), 1]);
+ Assert.Equal(705, message[f("packed_sint32"), 1]);
+ Assert.Equal(706L, message[f("packed_sint64"), 1]);
+ Assert.Equal(707u, message[f("packed_fixed32"), 1]);
+ Assert.Equal(708uL, message[f("packed_fixed64"), 1]);
+ Assert.Equal(709, message[f("packed_sfixed32"), 1]);
+ Assert.Equal(710L, message[f("packed_sfixed64"), 1]);
+ Assert.Equal(711F, message[f("packed_float"), 1]);
+ Assert.Equal(712D, message[f("packed_double"), 1]);
+ Assert.Equal(false, message[f("packed_bool"), 1]);
+ Assert.Equal(foreignBaz, message[f("packed_enum"), 1]);
}
}
}
\ No newline at end of file |