Ejemplo n.º 1
0
        public void TestToJson()
        {
            NEP6Contract nep6Contract = new NEP6Contract()
            {
                Script         = new byte[] { 0x00, 0x01 },
                ParameterList  = new ContractParameterType[] { ContractParameterType.Boolean, ContractParameterType.Integer },
                ParameterNames = new string[] { "param1", "param2" },
                Deployed       = false
            };

            JObject @object = nep6Contract.ToJson();
            JString jString = (JString)@object["script"];

            jString.Value.Should().Be(nep6Contract.Script.ToHexString());

            JBoolean jBoolean = (JBoolean)@object["deployed"];

            jBoolean.Value.Should().BeFalse();

            JArray parameters = (JArray)@object["parameters"];

            parameters.Count.Should().Be(2);

            jString = (JString)(parameters[0]["name"]);
            jString.Value.Should().Be("param1");
            jString = (JString)(parameters[0]["type"]);
            jString.Value.Should().Be(ContractParameterType.Boolean.ToString());

            jString = (JString)(parameters[1]["name"]);
            jString.Value.Should().Be("param2");
            jString = (JString)(parameters[1]["type"]);
            jString.Value.Should().Be(ContractParameterType.Integer.ToString());
        }