コード例 #1
0
        /// <summary>
        ///Peek 的测试
        ///</summary>
        public void PeekTestHelper <ValueT>()
        {
            SafeQueue <ValueT> target   = new SafeQueue <ValueT>(); // TODO: 初始化为适当的值
            ValueT             expected = default(ValueT);          // TODO: 初始化为适当的值
            ValueT             actual;

            actual = target.Peek();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
コード例 #2
0
    public void SafeQueue_peek_works()
    {
        var q = new SafeQueue <string>();

        Assert.IsNotNull(q);
        Assert.AreEqual(0, q.Count);
        q.Enqueue("a");
        Assert.AreEqual(1, q.Count);
        var result = q.Peek();

        Assert.AreEqual("a", result);
        result = q.Dequeue();
        Assert.AreEqual("a", result);
        result = q.Dequeue();
        Assert.AreEqual(null, result);
    }
コード例 #3
0
    public void SafeQueue_CantTellByDequeueIfQueueIsEmptyOrContainsNull()
    {
        var q = new SafeQueue <string>();

        Assert.IsNotNull(q);
        Assert.AreEqual(true, q.IsEmpty);
        q.Enqueue(null);
        Assert.AreEqual(false, q.IsEmpty);
        var result2 = q.Peek();

        Assert.AreEqual(null, result2);
        Assert.AreEqual(false, q.IsEmpty);
        result2 = q.Dequeue();
        Assert.AreEqual(true, q.IsEmpty);
        Assert.AreEqual(null, result2);
    }