Beispiel #1
0
        public void 繞行SafeCollection操作集合_不同執行緒同時對SafeCollection新增與刪除元素_不應擲出例外()
        {
            var safeCollection = new SafeCollection <int> {
                1, 2, 3, 4, 5
            };

            Task.Run(() =>
            {
                while (true)
                {
                    safeCollection.Add(0);
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    safeCollection.Remove(0);
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    safeCollection.Clear();
                }
            });

            Action action = () => IterateCollection(safeCollection).Wait();

            action.Should().NotThrow();
        }
        public void ResetVisualization()
        {
            _nextLocation  = Box.Empty;
            _verticalScale = -1;
            _boardInfo.Clear();

            Invalidate();
        }
Beispiel #3
0
        public void 清除含有3個元素的SafeCollection_清除成功_集合長度應為0()
        {
            var safeCollection = new SafeCollection <int> {
                1, 2, 3
            };

            safeCollection.Clear();
            const int expecetedCount = 0;

            safeCollection.Count.Should().Be(expecetedCount);
        }
Beispiel #4
0
 public void Clear()
 {
     tasks.Clear();
 }