示例#1
0
        public void BlockIsInvalidatedAfterChange()
        {
            var sut = new BlockChain.Block <MyData> (
                new MyData(108, "Hello"), null, new ProofOfWork());

            Assert.True(sut.IsValid());
            var blockJSON = sut.ToString().Replace("Hello", "Changed");

            sut = DeserializeObject <BlockChain.Block <MyData> > (blockJSON);
            Assert.False(sut.IsValid());
        }
示例#2
0
        public void BlockCanBeSerializedAndDeSerialized()
        {
            var sut =
                new BlockChain.Block <MyData> (
                    new MyData(
                        108, "Hello"),
                    null,
                    new ProofOfWork()
                    );
            var blockJSON = sut.ToString();

            sut = null;
            sut = DeserializeObject <BlockChain.Block <MyData> > (blockJSON);

            Assert.True(sut.IsValid());
        }