-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d7be19
commit 1b28667
Showing
1 changed file
with
71 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,71 @@ | ||
using Ipfs; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using Google.Protobuf; | ||
|
||
namespace Ipfs | ||
{ | ||
[TestClass] | ||
public class DagLinkTest | ||
{ | ||
[TestMethod] | ||
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); | ||
} | ||
|
||
[TestMethod] | ||
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); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd51201611803"; | ||
var link = new DagLink("a", "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding_EmptyName() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd512001803"; | ||
var link = new DagLink("", "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding_NullName() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd51803"; | ||
var link = new DagLink(null, "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
} | ||
} | ||
using Ipfs; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using Google.Protobuf; | ||
|
||
namespace Ipfs | ||
{ | ||
[TestClass] | ||
public class DagLinkTest | ||
{ | ||
[TestMethod] | ||
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); | ||
} | ||
|
||
[TestMethod] | ||
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); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd51201611803"; | ||
var link = new DagLink("a", "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding_EmptyName() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd512001803"; | ||
var link = new DagLink("", "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
[TestMethod] | ||
public void Encoding_NullName() | ||
{ | ||
var encoded = "0a22122023dca2a7429612378554b0bb5b85012dec00a17cc2c673f17d2b76a50b839cd51803"; | ||
var link = new DagLink(null, "QmQke7LGtfu3GjFP3AnrP8vpEepQ6C5aJSALKAq653bkRi", 3); | ||
var x = link.ToArray(); | ||
Assert.AreEqual(encoded, link.ToArray().ToHexString()); | ||
} | ||
|
||
[TestMethod] | ||
public void Null_Stream() | ||
{ | ||
ExceptionAssert.Throws(() => new DagLink((CodedInputStream)null)); | ||
ExceptionAssert.Throws(() => new DagLink((Stream)null)); | ||
} | ||
|
||
|
||
} | ||
} |