Exemplo n.º 1
0
        public void DefaultBlockShouldBeDeserializedCorrectly()
        {
            string json = "\"latest\"";
            DefaultBlock actual = _serializer.Deserialize<DefaultBlock>(json);
            DefaultBlock expected = DefaultBlock.Latest;
            Assert.IsTrue(Equals(expected, actual));

            json = "\"earliest\"";
            actual = _serializer.Deserialize<DefaultBlock>(json);
            expected = DefaultBlock.Earliest;
            Assert.IsTrue(Equals(expected, actual));

            json = "\"pending\"";
            actual = _serializer.Deserialize<DefaultBlock>(json);
            expected = DefaultBlock.Pending;
            Assert.IsTrue(Equals(expected, actual));

            json = "\"0X1A4\"";
            actual = _serializer.Deserialize<DefaultBlock>(json);
            expected = new DefaultBlock(420);
            Assert.IsTrue(Equals(expected, actual));
        }
Exemplo n.º 2
0
        public void DefaultBlockShouldBeSerializedCorrectly()
        {
            DefaultBlock db = DefaultBlock.Latest;
            string actual = _serializer.Serialize(db);
            string expected = "\"latest\"";
            Assert.IsTrue(String.Equals(expected, actual));

            db = DefaultBlock.Earliest;
            actual = _serializer.Serialize(db);
            expected = "\"earliest\"";
            Assert.IsTrue(String.Equals(expected, actual));

            db = DefaultBlock.Pending;
            actual = _serializer.Serialize(db);
            expected = "\"pending\"";
            Assert.IsTrue(String.Equals(expected, actual));

            db = new DefaultBlock(420);
            actual = _serializer.Serialize(db).ToUpperInvariant();
            expected = "\"0X1A4\"";
            Assert.IsTrue(String.Equals(expected, actual));
        }