• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TestAllTypes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TestAllTypes的典型用法代码示例。如果您正苦于以下问题:C# TestAllTypes类的具体用法?C# TestAllTypes怎么用?C# TestAllTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestAllTypes类属于命名空间,在下文中一共展示了TestAllTypes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EmptyMessageFieldDistinctFromMissingMessageField

 public void EmptyMessageFieldDistinctFromMissingMessageField()
 {
     // This demonstrates what we're really interested in...
     var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() };
     var message2 = new TestAllTypes(); // SingleForeignMessage is null
     EqualityTester.AssertInequality(message1, message2);
 }
开发者ID:senyu0210,项目名称:protobuf,代码行数:7,代码来源:GeneratedMessageTest.cs


示例2: UnknownFieldSetTest

 public UnknownFieldSetTest()
 {
     descriptor = TestAllTypes.Descriptor;
     allFields = TestUtil.GetAllSet();
     allFieldsData = allFields.ToByteString();
     emptyMessage = TestEmptyMessage.ParseFrom(allFieldsData);
     unknownFields = emptyMessage.UnknownFields;
 }
开发者ID:JuWell,项目名称:SmallNetGame,代码行数:8,代码来源:UnknownFieldSetTest.cs


示例3: AllSingleFields

        public void AllSingleFields()
        {
            var message = new TestAllTypes
            {
                SingleBool = true,
                SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
                SingleDouble = 23.5,
                SingleFixed32 = 23,
                SingleFixed64 = 1234567890123,
                SingleFloat = 12.25f,
                SingleForeignEnum = ForeignEnum.FOREIGN_BAR,
                SingleForeignMessage = new ForeignMessage { C = 10 },
                SingleImportEnum = ImportEnum.IMPORT_BAZ,
                SingleImportMessage = new ImportMessage { D = 20 },
                SingleInt32 = 100,
                SingleInt64 = 3210987654321,
                SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
                SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
                SinglePublicImportMessage = new PublicImportMessage { E = 54 },
                SingleSfixed32 = -123,
                SingleSfixed64 = -12345678901234,
                SingleSint32 = -456,
                SingleSint64 = -12345678901235,
                SingleString = "test\twith\ttabs",
                SingleUint32 = uint.MaxValue,
                SingleUint64 = ulong.MaxValue,
            };
            var actualText = JsonFormatter.Default.Format(message);

            // Fields in numeric order
            var expectedText = "{ " +
                "'singleInt32': 100, " +
                "'singleInt64': '3210987654321', " +
                "'singleUint32': 4294967295, " +
                "'singleUint64': '18446744073709551615', " +
                "'singleSint32': -456, " +
                "'singleSint64': '-12345678901235', " +
                "'singleFixed32': 23, " +
                "'singleFixed64': '1234567890123', " +
                "'singleSfixed32': -123, " +
                "'singleSfixed64': '-12345678901234', " +
                "'singleFloat': 12.25, " +
                "'singleDouble': 23.5, " +
                "'singleBool': true, " +
                "'singleString': 'test\\twith\\ttabs', " +
                "'singleBytes': 'AQIDBA==', " +
                "'singleNestedMessage': { 'bb': 35 }, " +
                "'singleForeignMessage': { 'c': 10 }, " +
                "'singleImportMessage': { 'd': 20 }, " +
                "'singleNestedEnum': 'FOO', " +
                "'singleForeignEnum': 'FOREIGN_BAR', " +
                "'singleImportEnum': 'IMPORT_BAZ', " +
                "'singlePublicImportMessage': { 'e': 54 }" +
                " }";
            AssertJson(expectedText, actualText);
        }
开发者ID:Holygitzdq,项目名称:ElVis,代码行数:56,代码来源:JsonFormatterTest.cs


示例4: DefaultValues

        public void DefaultValues()
        {
            // Single fields
            var message = new TestAllTypes();
            Assert.AreEqual(false, message.SingleBool);
            Assert.AreEqual(ByteString.Empty, message.SingleBytes);
            Assert.AreEqual(0.0, message.SingleDouble);
            Assert.AreEqual(0, message.SingleFixed32);
            Assert.AreEqual(0L, message.SingleFixed64);
            Assert.AreEqual(0.0f, message.SingleFloat);
            Assert.AreEqual(ForeignEnum.FOREIGN_UNSPECIFIED, message.SingleForeignEnum);
            Assert.IsNull(message.SingleForeignMessage);
            Assert.AreEqual(ImportEnum.IMPORT_ENUM_UNSPECIFIED, message.SingleImportEnum);
            Assert.IsNull(message.SingleImportMessage);
            Assert.AreEqual(0, message.SingleInt32);
            Assert.AreEqual(0L, message.SingleInt64);
            Assert.AreEqual(TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED, message.SingleNestedEnum);
            Assert.IsNull(message.SingleNestedMessage);
            Assert.IsNull(message.SinglePublicImportMessage);
            Assert.AreEqual(0, message.SingleSfixed32);
            Assert.AreEqual(0L, message.SingleSfixed64);
            Assert.AreEqual(0, message.SingleSint32);
            Assert.AreEqual(0L, message.SingleSint64);
            Assert.AreEqual("", message.SingleString);
            Assert.AreEqual(0U, message.SingleUint32);
            Assert.AreEqual(0UL, message.SingleUint64);

            // Repeated fields
            Assert.AreEqual(0, message.RepeatedBool.Count);
            Assert.AreEqual(0, message.RepeatedBytes.Count);
            Assert.AreEqual(0, message.RepeatedDouble.Count);
            Assert.AreEqual(0, message.RepeatedFixed32.Count);
            Assert.AreEqual(0, message.RepeatedFixed64.Count);
            Assert.AreEqual(0, message.RepeatedFloat.Count);
            Assert.AreEqual(0, message.RepeatedForeignEnum.Count);
            Assert.AreEqual(0, message.RepeatedForeignMessage.Count);
            Assert.AreEqual(0, message.RepeatedImportEnum.Count);
            Assert.AreEqual(0, message.RepeatedImportMessage.Count);
            Assert.AreEqual(0, message.RepeatedNestedEnum.Count);
            Assert.AreEqual(0, message.RepeatedNestedMessage.Count);
            Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count);
            Assert.AreEqual(0, message.RepeatedSfixed32.Count);
            Assert.AreEqual(0, message.RepeatedSfixed64.Count);
            Assert.AreEqual(0, message.RepeatedSint32.Count);
            Assert.AreEqual(0, message.RepeatedSint64.Count);
            Assert.AreEqual(0, message.RepeatedString.Count);
            Assert.AreEqual(0, message.RepeatedUint32.Count);
            Assert.AreEqual(0, message.RepeatedUint64.Count);

            // Oneof fields
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
        }
开发者ID:senyu0210,项目名称:protobuf,代码行数:56,代码来源:GeneratedMessageTest.cs


示例5: CloneOneofField

        public void CloneOneofField()
        {
            var original = new TestAllTypes
            {
                OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
            };

            var clone = original.Clone();
            Assert.AreNotSame(original, clone);
            Assert.AreEqual(original, clone);

            // We should have cloned the message
            original.OneofNestedMessage.Bb = 30;
            Assert.AreNotEqual(original, clone);
        }
开发者ID:caiolima,项目名称:webkit,代码行数:15,代码来源:GeneratedMessageTest.cs


示例6: CloneRepeatedMessageField

        public void CloneRepeatedMessageField()
        {
            var original = new TestAllTypes
            {
                RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } }
            };

            var clone = original.Clone();
            Assert.AreNotSame(original, clone);
            Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage);
            Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]);
            Assert.AreEqual(original, clone);

            clone.RepeatedNestedMessage[0].Bb = 30;
            Assert.AreNotEqual(original, clone);
        }
开发者ID:caiolima,项目名称:webkit,代码行数:16,代码来源:GeneratedMessageTest.cs


示例7: RoundTrip_RepeatedValues

        public void RoundTrip_RepeatedValues()
        {
            var message = new TestAllTypes
            {
                RepeatedBool = { true, false },
                RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) },
                RepeatedDouble = { -12.25, 23.5 },
                RepeatedFixed32 = { uint.MaxValue, 23 },
                RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
                RepeatedFloat = { 100f, 12.25f },
                RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR },
                RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
                RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED },
                RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
                RepeatedInt32 = { 100, 200 },
                RepeatedInt64 = { 3210987654321, long.MaxValue },
                RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG },
                RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
                RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
                RepeatedSfixed32 = { -123, 123 },
                RepeatedSfixed64 = { -12345678901234, 12345678901234 },
                RepeatedSint32 = { -456, 100 },
                RepeatedSint64 = { -12345678901235, 123 },
                RepeatedString = { "foo", "bar" },
                RepeatedUint32 = { uint.MaxValue, uint.MinValue },
                RepeatedUint64 = { ulong.MaxValue, uint.MinValue }
            };

            byte[] bytes = message.ToByteArray();
            TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
            Assert.AreEqual(message, parsed);
        }
开发者ID:senyu0210,项目名称:protobuf,代码行数:32,代码来源:GeneratedMessageTest.cs


示例8: RoundTrip_Empty

 public void RoundTrip_Empty()
 {
     var message = new TestAllTypes();
     // Without setting any values, there's nothing to write.
     byte[] bytes = message.ToByteArray();
     Assert.AreEqual(0, bytes.Length);
     TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
     Assert.AreEqual(message, parsed);
 }
开发者ID:senyu0210,项目名称:protobuf,代码行数:9,代码来源:GeneratedMessageTest.cs


示例9: RoundTrip_SingleValues

        public void RoundTrip_SingleValues()
        {
            var message = new TestAllTypes
            {
                SingleBool = true,
                SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
                SingleDouble = 23.5,
                SingleFixed32 = 23,
                SingleFixed64 = 1234567890123,
                SingleFloat = 12.25f,
                SingleForeignEnum = ForeignEnum.FOREIGN_BAR,
                SingleForeignMessage = new ForeignMessage { C = 10 },
                SingleImportEnum = ImportEnum.IMPORT_BAZ,
                SingleImportMessage = new ImportMessage { D = 20 },
                SingleInt32 = 100,
                SingleInt64 = 3210987654321,
                SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
                SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
                SinglePublicImportMessage = new PublicImportMessage { E = 54 },
                SingleSfixed32 = -123,
                SingleSfixed64 = -12345678901234,
                SingleSint32 = -456,
                SingleSint64 = -12345678901235,
                SingleString = "test",
                SingleUint32 = uint.MaxValue,
                SingleUint64 = ulong.MaxValue
            };

            byte[] bytes = message.ToByteArray();
            TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
            Assert.AreEqual(message, parsed);
        }
开发者ID:senyu0210,项目名称:protobuf,代码行数:32,代码来源:GeneratedMessageTest.cs


示例10: AnyUnknownType

 public void AnyUnknownType()
 {
     // The default type registry doesn't have any types in it.
     var message = new TestAllTypes();
     var any = Any.Pack(message);
     Assert.Throws<InvalidOperationException>(() => JsonFormatter.Default.Format(any));
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:7,代码来源:JsonFormatterTest.cs


示例11: NullStringAndBytesRejected

 public void NullStringAndBytesRejected()
 {
     var message = new TestAllTypes();
     Assert.Throws<ArgumentNullException>(() => message.SingleString = null);
     Assert.Throws<ArgumentNullException>(() => message.OneofString = null);
     Assert.Throws<ArgumentNullException>(() => message.SingleBytes = null);
     Assert.Throws<ArgumentNullException>(() => message.OneofBytes = null);
 }
开发者ID:senyu0210,项目名称:protobuf,代码行数:8,代码来源:GeneratedMessageTest.cs


示例12: CloneSingleMessageField

        public void CloneSingleMessageField()
        {
            var original = new TestAllTypes
            {
                SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
            };

            var clone = original.Clone();
            Assert.AreNotSame(original, clone);
            Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage);
            Assert.AreEqual(original, clone);

            clone.SingleNestedMessage.Bb = 30;
            Assert.AreNotEqual(original, clone);
        }
开发者ID:senyu0210,项目名称:protobuf,代码行数:15,代码来源:GeneratedMessageTest.cs


示例13: WriteValue_Message

 public void WriteValue_Message()
 {
     var value = new TestAllTypes { SingleInt32 = 100, SingleInt64 = 3210987654321L };
     AssertWriteValue(value, "{ 'singleInt32': 100, 'singleInt64': '3210987654321' }");
 }
开发者ID:ChemiCoder,项目名称:protobuf,代码行数:5,代码来源:JsonFormatterTest.cs


示例14: OneofProperties

        public void OneofProperties()
        {
            // Switch the oneof case between each of the different options, and check everything behaves
            // as expected in each case.
            var message = new TestAllTypes();
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);

            message.OneofString = "sample";
            Assert.AreEqual("sample", message.OneofString);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase);

            var bytes = ByteString.CopyFrom(1, 2, 3);
            message.OneofBytes = bytes;
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual(bytes, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase);

            message.OneofUint32 = 20;
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(20, message.OneofUint32);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase);

            var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 };
            message.OneofNestedMessage = nestedMessage;
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.AreEqual(nestedMessage, message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase);

            message.ClearOneofField();
            Assert.AreEqual("", message.OneofString);
            Assert.AreEqual(0, message.OneofUint32);
            Assert.AreEqual(ByteString.Empty, message.OneofBytes);
            Assert.IsNull(message.OneofNestedMessage);
            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
        }
开发者ID:senyu0210,项目名称:protobuf,代码行数:48,代码来源:GeneratedMessageTest.cs


示例15: CustomDiagnosticMessage_Nested

 public void CustomDiagnosticMessage_Nested()
 {
     var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } };
     Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
     Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
 }
开发者ID:2php,项目名称:protobuf,代码行数:6,代码来源:GeneratedMessageTest.cs


示例16: UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown

 public void UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown()
 {
     // *Maybe* we should hold off on writing the "[" until we find that we've got at least one value to write...
     // but this is what happens at the moment, and it doesn't seem too awful.
     var message = new TestAllTypes { RepeatedForeignEnum = { (ForeignEnum) 200, (ForeignEnum) 100 } };
     AssertJson("{ 'repeatedForeignEnum': [ ] }", JsonFormatter.Default.Format(message));
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:7,代码来源:JsonFormatterTest.cs


示例17: Passthrough

 [TestCase("a\u0605b", "a\u0605b")] // Passthrough (note lack of double backslash...)
 public void SimpleNonAscii(string text, string encoded)
 {
     var message = new TestAllTypes { SingleString = text };
     AssertJson("{ 'singleString': '" + encoded + "' }", JsonFormatter.Default.Format(message));
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:6,代码来源:JsonFormatterTest.cs


示例18: UnknownEnumValueOmitted_RepeatedField

 public void UnknownEnumValueOmitted_RepeatedField()
 {
     var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } };
     AssertJson("{ 'repeatedForeignEnum': [ 'FOREIGN_BAZ', 'FOREIGN_FOO' ] }", JsonFormatter.Default.Format(message));
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:5,代码来源:JsonFormatterTest.cs


示例19: UnknownEnumValueOmitted_SingleField

 public void UnknownEnumValueOmitted_SingleField()
 {
     var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 };
     AssertJson("{ }", JsonFormatter.Default.Format(message));
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:5,代码来源:JsonFormatterTest.cs


示例20: DoubleRepresentations

 public void DoubleRepresentations(double value, string expectedValueText)
 {
     var message = new TestAllTypes { SingleDouble = value };
     string actualText = JsonFormatter.Default.Format(message);
     string expectedText = "{ 'singleDouble': " + expectedValueText + " }";
     AssertJson(expectedText, actualText);
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:7,代码来源:JsonFormatterTest.cs



注:本文中的TestAllTypes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestBuildManager类代码示例发布时间:2022-05-24
下一篇:
C# Test.List类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap