本文整理汇总了C#中Port.PostElement方法的典型用法代码示例。如果您正苦于以下问题:C# Port.PostElement方法的具体用法?C# Port.PostElement怎么用?C# Port.PostElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port.PostElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostElementThenTestForElement
public void PostElementThenTestForElement()
{
int tmp;
var p = new Port<int> ();
; var elem = new PortElement<int> (99);
p.PostElement (elem);
Assert.AreEqual (1, p.ItemCount, "#1");
var res = p.TestForElement ();
Assert.AreEqual (elem, res, "#2");
Assert.AreEqual (0, p.ItemCount, "#3");
Assert.AreEqual (null, res.Owner, "#4");
}
示例2: PostElementPrependOnTheQueue
public void PostElementPrependOnTheQueue()
{
Port<int> p = new Port<int> ();
p.Post (10);
p.Post (20);
p.PostElement (new PortElement<int> (30));
Assert.AreEqual (30, (int)p, "#1");
Assert.AreEqual (10, (int)p, "#2");
Assert.AreEqual (20, (int)p, "#3");
}
示例3: PostElementBad
public void PostElementBad()
{
var p = new Port<int> ();
; var elem = new PortElement<double> (99);
try {
p.PostElement (elem);
Assert.Fail ("#1");
} catch (InvalidCastException) {} /*LAMEIMPL, stupid exception to throw*/
try {
p.PostElement (null);
Assert.Fail ("#2");
} catch (NullReferenceException) {} /*LAMEIMPL, stupid exception to throw*/
}
示例4: PostElementCausesLinking
public void PostElementCausesLinking()
{
var p = new Port<int> ();
p.Post (10);
p.PostElement (new PortElement<int> (20));
p.Post (30);
var r0 = p.TestForElement ();
var r1 = r0.Next;
Assert.IsNotNull (r1, "#1");
var r2 = r1.Next;
Assert.IsNotNull (r2, "#1");
Assert.AreEqual (r1, r2.Previous, "#2");
Assert.AreEqual (r2, r1.Previous, "#3");
}
示例5: LinkStateAfterPostElement
public void LinkStateAfterPostElement()
{
Port<int> p = new Port<int> ();
p.Post (10);
p.Post (20);
p.PostElement (new PortElement<int> (30));
p.PostElement (new PortElement<int> (40));
IPortReceive rec = p;
IPortElement a = (IPortElement)rec.GetItems () [0];
IPortElement b = (IPortElement)rec.GetItems () [1];
IPortElement c = (IPortElement)rec.GetItems () [2];
IPortElement d = (IPortElement)rec.GetItems () [3];
Assert.AreEqual (b, a.Next, "#1");
Assert.AreEqual (c, b.Next, "#2");
Assert.AreEqual (d, c.Next, "#3");
Assert.AreEqual (a, d.Next, "#4");
Assert.AreEqual (d, a.Previous, "#5");
Assert.AreEqual (a, b.Previous, "#6");
Assert.AreEqual (b, c.Previous, "#7");
Assert.AreEqual (c, d.Previous, "#8");
Assert.AreEqual (40, a.Item, "#9");
Assert.AreEqual (30, b.Item, "#10");
Assert.AreEqual (10, c.Item, "#11");
Assert.AreEqual (20, d.Item, "#12");
}