forked from Ashuaidehao/NEO3-GUI
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9498d0f
commit 545e8fb
Showing
34 changed files
with
817 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo; | ||
using Neo.SmartContract; | ||
using Neo.VM; | ||
using Neo.VM.Types; | ||
|
||
namespace neo3_gui.tests | ||
{ | ||
[TestClass] | ||
public class JsonConverter_Test | ||
{ | ||
[TestMethod] | ||
public void Test() | ||
{ | ||
var data = "1234".HexToBytes(); | ||
StackItem item = new ByteString(data); | ||
var json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
StackItem item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json,item2.SerializeJson()); | ||
|
||
item = new Neo.VM.Types.Buffer(data); | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
item = new Integer(20); | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
item = true; | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
item = new Pointer(data, 1); | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
item = StackItem.Null; | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
var list = new List<StackItem>() | ||
{ | ||
1, 2, true, false, data,StackItem.Null | ||
}; | ||
item = new Neo.VM.Types.Array(list); | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
item = new Neo.VM.Types.Struct(list); | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
|
||
var map = new Neo.VM.Types.Map(); | ||
map[1] = true; | ||
map[2] = false; | ||
map["a"] = "A"; | ||
map["b"] = StackItem.Null; | ||
|
||
item=map; | ||
json = item.SerializeJson(); | ||
Console.WriteLine(json); | ||
item2 = json.DeserializeJson<StackItem>(); | ||
Assert.AreEqual(json, item2.SerializeJson()); | ||
|
||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.