本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting.ToJson方法的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting.ToJson怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting
的用法示例。
在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting.ToJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtTest
public void ExtTest()
{
var obj = new { state = 0, msg = "ddddd", data = new { test = "111", tds = "dsss" } };
var timer01 = CodeTimer.Time("normal", 20 * 10000,
() => { var str = new JavaScriptSerializer().Serialize(obj); });
var timer02 = CodeTimer.Time("ext", 20 * 10000, () => { var str = obj.ToJson(); });
Console.WriteLine(timer01.ToString());
Console.WriteLine(timer02.ToString());
}
示例2: ShouldImportProperties
public void ShouldImportProperties()
{
var obj = new
{
IsSystem = true,
BlockTypeId = 1,
Zone = "TestZone",
Order = 3,
Name = "FooInstance",
OutputCacheDuration = 0
};
var json = obj.ToJson();
var block = Block.FromJson( json );
Assert.AreEqual( obj.Name, block.Name );
Assert.AreEqual( obj.IsSystem, block.IsSystem );
}
示例3: ShouldImportBlockType
public void ShouldImportBlockType()
{
var obj = new
{
IsSystem = true,
BlockTypeId = 1,
Zone = "TestZone",
Order = 3,
Name = "FooInstance",
OutputCacheDuration = 0,
BlockType = new
{
IsSystem = false,
Path = "Test Path",
Name = "Test Name",
Description = "Test desc"
}
};
var json = obj.ToJson();
var block = Block.FromJson( json );
var blockType = block.BlockType;
Assert.IsNotNull( blockType );
Assert.AreEqual( blockType.Name, obj.BlockType.Name );
}