本文整理汇总了C#中net.named_data.jndn.Interest.getLink方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.getLink方法的具体用法?C# Interest.getLink怎么用?C# Interest.getLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Interest
的用法示例。
在下文中一共展示了Interest.getLink方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testInterestLinkObjectWrongContentType
public void testInterestLinkObjectWrongContentType()
{
Interest interest = new Interest();
try {
interest.wireDecode(new Blob(InterestWithLinkWrongContentType,
false));
} catch (Exception ex) {
Assert.Fail("Decoding InterestWithLinkWrongContentType: "
+ ex.Message);
}
try {
interest.getLink();
Assert.Fail("Expected error decoding a link with the wrong content type");
} catch (Exception ex_0) {
}
}
示例2: testInterestSelectedDelegation
public void testInterestSelectedDelegation()
{
Link link = new Link();
link.setName(new Name("test"));
link.addDelegation(10, new Name("/test1"));
link.addDelegation(20, new Name("/test2"));
link.addDelegation(100, new Name("/test3"));
try {
keyChain.sign(link, certificateName);
} catch (SecurityException ex) {
Assert.Fail(ex.Message);
}
Blob linkEncoding = link.wireEncode();
Interest interestA = new Interest();
interestA.setLinkWireEncoding(linkEncoding);
Assert.AssertTrue(interestA.getSelectedDelegationIndex() < 0);
interestA.setSelectedDelegationIndex(link.getDelegations().find(
new Name("test2")));
Assert.AssertTrue(interestA.getSelectedDelegationIndex() >= 0);
Link link2 = null;
try {
link2 = interestA.getLink();
} catch (Exception ex_0) {
Assert.Fail(ex_0.Message);
}
Assert.AssertEquals(
new Name("test2"),
link2.getDelegations()
.get(interestA.getSelectedDelegationIndex()).getName());
interestA.setSelectedDelegationIndex(-1);
Assert.AssertTrue(interestA.getSelectedDelegationIndex() < 0);
}
示例3: testInterestLinkObjectNoMetaInfo
public void testInterestLinkObjectNoMetaInfo()
{
Interest interest = new Interest();
try {
interest.wireDecode(new Blob(InterestWithLinkNoMetaInfo, false));
} catch (Exception ex) {
Assert.Fail("Decoding InterestWithLinkNoMetaInfo: " + ex.Message);
}
try {
interest.getLink();
Assert.Fail("Expected error decoding a link with no meta info");
} catch (Exception ex_0) {
}
}
示例4: testInterestLinkObject
////////////////////////////////////
// Tests from ndn-cxx interest.t.cpp
////////////////////////////////////
public void testInterestLinkObject()
{
Link link1 = new Link();
link1.setName(new Name("test"));
link1.addDelegation(10, new Name("/test1"));
link1.addDelegation(20, new Name("/test2"));
link1.addDelegation(100, new Name("/test3"));
try {
keyChain.sign(link1, certificateName);
} catch (SecurityException ex) {
Assert.Fail(ex.Message);
}
Blob linkEncoding = link1.wireEncode();
Interest interestA = new Interest();
Link link2 = null;
try {
interestA.setLinkWireEncoding(linkEncoding);
link2 = interestA.getLink();
} catch (Exception ex_0) {
Assert.Fail(ex_0.Message);
}
Assert.AssertTrue(link2 != null);
Name name = link2.getName();
Assert.AssertEquals(new Name("test"), name);
DelegationSet delegations = link2.getDelegations();
for (int i = 0; i < delegations.size(); ++i) {
if (i == 0) {
Assert.AssertEquals(10, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test1"), delegations.get(i).getName());
}
if (i == 1) {
Assert.AssertEquals(20, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test2"), delegations.get(i).getName());
}
if (i == 2) {
Assert.AssertEquals(100, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test3"), delegations.get(i).getName());
}
}
interestA.setLinkWireEncoding(new Blob(LINK, false));
Link link3 = null;
try {
link3 = interestA.getLink();
} catch (Exception ex_1) {
Assert.Fail(ex_1.Message);
}
Assert.AssertEquals(2, link3.getDelegations().size());
interestA.unsetLink();
Assert.AssertEquals(false, interestA.hasLink());
}
示例5: testEncodeDecodeInterestWithLink
public void testEncodeDecodeInterestWithLink()
{
Link link1 = new Link();
link1.setName(new Name("test"));
link1.addDelegation(10, new Name("/test1"));
link1.addDelegation(20, new Name("/test2"));
link1.addDelegation(100, new Name("/test3"));
try {
keyChain.sign(link1, certificateName);
} catch (SecurityException ex) {
Assert.Fail(ex.Message);
}
Interest interestA = new Interest();
interestA.setName(new Name("/Test/Encode/Decode/With/Link"));
interestA.setChildSelector(1);
interestA.setInterestLifetimeMilliseconds(10000);
interestA.setLinkWireEncoding(link1.wireEncode());
Blob interestEncoding = interestA.wireEncode();
Interest interestB = new Interest();
try {
interestB.wireDecode(interestEncoding);
} catch (EncodingException ex_0) {
Assert.Fail(ex_0.Message);
}
Assert.AssertEquals(interestA.getName(), interestB.getName());
Link link2 = null;
try {
link2 = interestB.getLink();
} catch (Exception ex_1) {
Assert.Fail("interestB.getLink(): " + ex_1.Message);
}
Assert.AssertTrue("Interest link object not specified", link2 != null);
DelegationSet delegations = link2.getDelegations();
for (int i = 0; i < delegations.size(); ++i) {
if (i == 0) {
Assert.AssertEquals(10, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test1"), delegations.get(i).getName());
}
if (i == 1) {
Assert.AssertEquals(20, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test2"), delegations.get(i).getName());
}
if (i == 2) {
Assert.AssertEquals(100, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test3"), delegations.get(i).getName());
}
}
}
示例6: testDecodeInterestWithLinkNonDecreasingOrder
public void testDecodeInterestWithLinkNonDecreasingOrder()
{
Interest interest = new Interest();
Link link = null;
try {
interest.wireDecode(new Blob(InterestWithLinkNonDecreasingOrder,
false));
link = interest.getLink();
} catch (Exception ex) {
Assert.Fail("Decoding InterestWithLinkNonDecreasingOrder: "
+ ex.Message);
}
Assert.AssertTrue(interest.getSelectedDelegationIndex() >= 0);
Assert.AssertEquals(new Name("ndn"),
link.getDelegations()
.get(interest.getSelectedDelegationIndex()).getName());
}
示例7: testDecodeInterestWithLink
public void testDecodeInterestWithLink()
{
Interest interest = new Interest();
Link link = null;
try {
interest.wireDecode(new Blob(InterestWithLink, false));
link = interest.getLink();
} catch (Exception ex) {
Assert.Fail("Decoding InterestWithLink: " + ex.Message);
}
Assert.AssertTrue("Interest link object not specified", link != null);
Assert.AssertEquals(new Name("/local/ndn/prefix"), link.getName());
DelegationSet delegations = link.getDelegations();
for (int i = 0; i < delegations.size(); ++i) {
if (i == 0) {
Assert.AssertEquals(10, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("local"), delegations.get(i).getName());
}
if (i == 1) {
Assert.AssertEquals(20, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("ndn"), delegations.get(i).getName());
}
}
Assert.AssertTrue("Interest selected delegation not specified",
interest.getSelectedDelegationIndex() >= 0);
Assert.AssertEquals(new Name("local"),
delegations.get(interest.getSelectedDelegationIndex())
.getName());
}