当前位置: 首页>>代码示例>>C#>>正文


C# StringBuilder.AppendSerialization方法代码示例

本文整理汇总了C#中StringBuilder.AppendSerialization方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendSerialization方法的具体用法?C# StringBuilder.AppendSerialization怎么用?C# StringBuilder.AppendSerialization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuilder的用法示例。


在下文中一共展示了StringBuilder.AppendSerialization方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize_ResultFromAppendSerialization_ReturnsOriginalObject

        public void Deserialize_ResultFromAppendSerialization_ReturnsOriginalObject()
        {
            List<String> source = GenerateRandomListOfString();
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendSerialization(source);
            String serializedString = stringBuilder.ToString();

            List<String> result = serializedString.Deserialize<List<String>>();
            Assert.IsNotNull(result);
            Assert.AreEqual(String.Join(",", source), String.Join(",", result));
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:11,代码来源:SerializeTests.cs

示例2: AppendSerialization_CustomFormatterForEnumerable_SerializeMethodOfFormatterCalledWithEnumerableToList

            AppendSerialization_CustomFormatterForEnumerable_SerializeMethodOfFormatterCalledWithEnumerableToList()
        {
            String[] list = GenerateRandomListOfString().ToArray();
            IEnumerable<String> enumerable = list;

            Mock<IFormatter> mockFormatter = new Mock<IFormatter>();
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendSerialization(enumerable, formatter: mockFormatter.Object);
            String result = stringBuilder.ToString();
            mockFormatter.Verify(f => f.Serialize(It.IsAny<Stream>(), It.IsAny<List<String>>()), Times.Once(),
                                 "The IEnumerable should be converted to a list before being sent to the formatter.");
            mockFormatter.Verify(f => f.Serialize(It.IsAny<Stream>(), list), Times.Once());
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:13,代码来源:SerializeTests.cs

示例3: AppendSerialization_CustomFormatter_SerializeMethodOfFormatterCalledWithObj

 public void AppendSerialization_CustomFormatter_SerializeMethodOfFormatterCalledWithObj()
 {
     object obj = Random.RandomString();
     Mock<IFormatter> mockFormatter = new Mock<IFormatter>();
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.AppendSerialization(obj, formatter: mockFormatter.Object);
     String result = stringBuilder.ToString();
     mockFormatter.Verify(f => f.Serialize(It.IsAny<Stream>(), obj), Times.Once());
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:9,代码来源:SerializeTests.cs

示例4: AppendSerialization_NullInput_ThrowsArgumentNullException

 public void AppendSerialization_NullInput_ThrowsArgumentNullException()
 {
     StringBuilder stringBuilder = new StringBuilder();
     // ReSharper disable AssignNullToNotNullAttribute
     stringBuilder.AppendSerialization(null);
     // ReSharper restore AssignNullToNotNullAttribute
     String result = stringBuilder.ToString();
     Assert.AreEqual("", result);
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:9,代码来源:SerializeTests.cs

示例5: AppendSerialization_UnicodeStringsInputAsObject_StringBuilderContainsValidBase64

 public void AppendSerialization_UnicodeStringsInputAsObject_StringBuilderContainsValidBase64()
 {
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.AppendSerialization((Object) Random.RandomString());
     String result = stringBuilder.ToString();
     Assert.AreNotEqual("", result);
     Assert.IsTrue(ValidBase64.IsMatch(result));
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:8,代码来源:SerializeTests.cs

示例6: AppendSerialization_ListOfIntsInput_StringBuilderContainsValidBase64

 public void AppendSerialization_ListOfIntsInput_StringBuilderContainsValidBase64()
 {
     StringBuilder stringBuilder = new StringBuilder();
     List<int> listOfInts = Enumerable.Range(Random.Next(1, 1000), Random.Next(10, 1000)).ToList();
     stringBuilder.AppendSerialization(listOfInts);
     String result = stringBuilder.ToString();
     Assert.AreNotEqual("", result);
     Assert.IsTrue(ValidBase64.IsMatch(result));
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:9,代码来源:SerializeTests.cs


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