public void Encoding_NullName() { var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd51803"; var link = new DagLink(null, "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); var x = link.ToArray(); Assert.AreEqual(encoded, link.ToArray().ToHexString()); }
public void Creating() { var link = new DagLink("abc", "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", 5); Assert.AreEqual("abc", link.Name); Assert.AreEqual("QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", link.Hash); Assert.AreEqual(5, link.Size); }
public void Cloning() { var link = new DagLink("abc", "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", 5); var clone = new DagLink(link); Assert.AreEqual("abc", clone.Name); Assert.AreEqual("QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", clone.Hash); Assert.AreEqual(5, clone.Size); }
public void Cid_V1() { var link = new DagLink("hello", "zB7NCdng5WffuNCgHu4PhDj7nbtuVrhPc2pMhanNxYKRsECdjX9nd44g6CRu2xNrj2bG2NNaTsveL5zDGWhbfiug3VekW", 11); Assert.AreEqual("hello", link.Name); Assert.AreEqual(1, link.Id.Version); Assert.AreEqual("raw", link.Id.ContentType); Assert.AreEqual("sha2-512", link.Id.Hash.Algorithm.Name); Assert.AreEqual(11, link.Size); }
/// <summary> /// Removes a link. /// </summary> /// <param name="link"> /// The <see cref="DagLink"/> to remove. /// </param> /// <returns> /// A new <see cref="DagNode"/> with the <paramref name="link"/> /// removed. /// </returns> /// <remarks> /// A <b>DagNode</b> is immutable. /// <para> /// No exception is raised if the <paramref name="link"/> does /// not exist. /// </para> /// </remarks> public DagNode RemoveLink(DagLink link) { return(RemoveLinks(new[] { link })); }
/// <summary> /// Adds a link. /// </summary> /// <param name="link"> /// The <see cref="DagLink"/> to add. /// </param> /// <returns> /// A new <see cref="DagNode"/> with the existing and new /// link. /// </returns> /// <remarks> /// A <b>DagNode</b> is immutable. /// </remarks> public DagNode AddLink(DagLink link) { return(AddLinks(new[] { link })); }