public void ToLink_With_Name() { var abc = Encoding.UTF8.GetBytes("abc"); var node = new DagNode(abc); var link = node.ToLink("abc"); Assert.AreEqual("abc", link.Name); Assert.AreEqual(node.Id, link.Id); Assert.AreEqual(node.Size, link.Size); }
public void ToLink() { var abc = Encoding.UTF8.GetBytes("abc"); var node = new DagNode(abc); var link = node.ToLink(); Assert.AreEqual("", link.Name); Assert.AreEqual(node.Hash, link.Hash); Assert.AreEqual(node.Size, link.Size); }
public void RemoveLink() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var b = Encoding.UTF8.GetBytes("b"); var bnode = new DagNode(b); var c = Encoding.UTF8.GetBytes("c"); var cnode = new DagNode(c, new[] { anode.ToLink(), bnode.ToLink() }); var dnode = cnode.RemoveLink(anode.ToLink()); Assert.IsFalse(Object.ReferenceEquals(dnode, cnode)); Assert.AreEqual(1, dnode.DataBytes.Length); Assert.AreEqual(1, dnode.Links.Count()); Assert.AreEqual(bnode.Id, dnode.Links.First().Id); Assert.AreEqual(bnode.Size, dnode.Links.First().Size); RoundtripTest(cnode); }
public void LinkOnlyDAG() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var alink = anode.ToLink("a"); var node = new DagNode(null, new[] { alink }); Assert.AreEqual(0, node.DataBytes.Length); Assert.AreEqual(1, node.Links.Count()); Assert.AreEqual("QmVdMJFGTqF2ghySAmivGiQvsr9ZH7ujnNGBkLNNCe4HUE", (string)node.Id); Assert.AreEqual(43, node.Size); RoundtripTest(node); }
public void Links_are_Sorted() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var alink = anode.ToLink("a"); var b = Encoding.UTF8.GetBytes("b"); var bnode = new DagNode(b); var blink = bnode.ToLink("b"); var ab = Encoding.UTF8.GetBytes("ab"); var node = new DagNode(ab, new[] { blink, alink }); CollectionAssert.AreEqual(ab, node.DataBytes); Assert.AreEqual(2, node.Links.Count()); Assert.AreEqual("Qma5sYpEc9hSYdkuXpMDJYem95Mj7hbEd9C412dEQ4ZkfP", (string)node.Id); }
public void MultipleLinksOnlyDAG() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var alink = anode.ToLink("a"); var b = Encoding.UTF8.GetBytes("b"); var bnode = new DagNode(b); var blink = bnode.ToLink("b"); var node = new DagNode(null, new[] { alink, blink }); Assert.AreEqual(0, node.DataBytes.Length); Assert.AreEqual(2, node.Links.Count()); Assert.AreEqual("QmbNgNPPykP4YTuAeSa3DsnBJWLVxccrqLUZDPNQfizGKs", (string)node.Id); RoundtripTest(node); }
public void AddLink() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var b = Encoding.UTF8.GetBytes("b"); var bnode = new DagNode(b); var cnode = bnode.AddLink(anode.ToLink()); Assert.IsFalse(Object.ReferenceEquals(bnode, cnode)); Assert.AreEqual(1, cnode.DataBytes.Length); Assert.AreEqual(1, cnode.Links.Count()); Assert.AreEqual(anode.Id, cnode.Links.First().Id); Assert.AreEqual(anode.Size, cnode.Links.First().Size); RoundtripTest(cnode); }
public void MultipleLinksDataDAG() { var a = Encoding.UTF8.GetBytes("a"); var anode = new DagNode(a); var alink = anode.ToLink("a"); var b = Encoding.UTF8.GetBytes("b"); var bnode = new DagNode(b); var blink = bnode.ToLink("b"); var ab = Encoding.UTF8.GetBytes("ab"); var node = new DagNode(ab, new[] { alink, blink }); CollectionAssert.AreEqual(ab, node.Data); Assert.AreEqual(2, node.Links.Count()); Assert.AreEqual("Qma5sYpEc9hSYdkuXpMDJYem95Mj7hbEd9C412dEQ4ZkfP", node.Hash); RoundtripTest(node); }