コード例 #1
0
        public void _1_Add_Should_overwrite_oldest_item_When_full()
        {
            OtherCircularBuffer <char> collection = new OtherCircularBuffer <char>(5);

            foreach (char c in "mindplugg")
            {
                collection.Add(c);
            }

            Assert.Equal("plugg", new string(collection.ToArray()));
        }
コード例 #2
0
        public void _1_Should_be_able_to_add_and_get_items_back()
        {
            OtherCircularBuffer <char> collection = new OtherCircularBuffer <char>(42);

            foreach (char c in "mindplugg")
            {
                collection.Add(c);
            }

            Assert.Equal("mindplugg", new string(collection.ToArray()));
        }
コード例 #3
0
        public void _1_Clear_Should_clear_items()
        {
            OtherCircularBuffer <char> collection = new OtherCircularBuffer <char>(42);

            foreach (char c in "mindplugg")
            {
                collection.Add(c);
            }

            collection.Clear();

            Assert.Equal(string.Empty, new string(collection.ToArray()));
        }
コード例 #4
0
        public void _B_Clear_Should_remove_item_references()
        {
            OtherCircularBuffer <object> collection = new OtherCircularBuffer <object>(42);

            object        o         = new object();
            WeakReference reference = new WeakReference(o);

            collection.Add(o);

            o = null;
            collection.Clear();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.False(reference.IsAlive, "reference is still alive, switch in Release configuration is this is not expected");
        }