本文整理汇总了C#中Port.TestForMultipleElements方法的典型用法代码示例。如果您正苦于以下问题:C# Port.TestForMultipleElements方法的具体用法?C# Port.TestForMultipleElements怎么用?C# Port.TestForMultipleElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port.TestForMultipleElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestForMultipleElements
public void TestForMultipleElements()
{
var p = new Port<int> ();
p.Post (33);
p.Post (55);
p.Post (44);
IPortElement[] res = p.TestForMultipleElements (2);
Assert.IsNotNull (res, "#1");
Assert.AreEqual (2, res.Length, "#2");
Assert.AreEqual (1, p.ItemCount, "#3");
Assert.AreEqual (33, res [0].Item, "#4");
Assert.AreEqual (55, res [1].Item, "#5");
res = p.TestForMultipleElements (2);
Assert.IsNull (res, "#6");
Assert.AreEqual (1, p.ItemCount, "#7");
}
示例2: LinkStateAfterATestForMultipleElements
public void LinkStateAfterATestForMultipleElements()
{
var p = new Port<int> ();
p.Post (33);
p.Post (55);
p.Post (44);
p.Post (77);
IPortElement[] res = p.TestForMultipleElements (2);
IPortElement a = res [0];
IPortElement b = res [1];
IPortElement c = (IPortElement)((IPortReceive)p).GetItems ()[0];
IPortElement d = (IPortElement)((IPortReceive)p).GetItems ()[1];
Assert.AreEqual (b, a.Next, "#1");
Assert.AreEqual (c, b.Next, "#2");//LAMEIMPL MS doesn't unlink the resulting elements
Assert.AreEqual (d, c.Next, "#3");
Assert.AreEqual (c, d.Next, "#4");
Assert.AreEqual (d, a.Previous, "#5");
Assert.AreEqual (d, b.Previous, "#6"); //LAMEIMPL now this is SICK, previos always point to the last element
Assert.AreEqual (d, c.Previous, "#7");
Assert.AreEqual (c, d.Previous, "#8");
}