Summary

Class:WireMock.Util.ConcurentObservableCollection`1
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Util\ConcurentObservableCollection.cs
Covered lines:20
Uncovered lines:14
Coverable lines:34
Total lines:77
Line coverage:58.8%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
ClearItems()0010
RemoveItem(...)0010
InsertItem(...)0010
SetItem(...)0000
MoveItem(...)0000
.ctor()0010
.ctor(...)0000
.ctor(...)0000

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Util\ConcurentObservableCollection.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Collections.ObjectModel;
 3
 4namespace WireMock.Util
 5{
 6    /// <summary>
 7    /// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe
 8    /// </summary>
 9    /// <typeparam name="T">The type of elements in the collection.</typeparam>
 10    /// <inheritdoc cref="ObservableCollection{T}" />
 11    public class ConcurentObservableCollection<T> : ObservableCollection<T>
 12    {
 5413        private readonly object _lockObject = new object();
 14
 15        /// <summary>
 16        /// Initializes a new instance of the <see cref="T:WireMock.Util.ConcurentObservableCollection`1" /> class.
 17        /// </summary>
 16218        public ConcurentObservableCollection() { }
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="ConcurentObservableCollection{T}"/> class that contains element
 22        /// </summary>
 23        /// <param name="list">The list from which the elements are copied.</param>
 024        public ConcurentObservableCollection(List<T> list) : base(list) { }
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="ConcurentObservableCollection{T}"/> class that contains element
 28        /// </summary>
 29        /// <param name="collection">The collection from which the elements are copied.</param>
 030        public ConcurentObservableCollection(IEnumerable<T> collection) : base(collection) { }
 31
 32        /// <inheritdoc cref="ObservableCollection{T}.ClearItems"/>
 33        protected override void ClearItems()
 134        {
 135            lock (_lockObject)
 136            {
 137                base.ClearItems();
 138            }
 139        }
 40
 41        /// <inheritdoc cref="ObservableCollection{T}.RemoveItem"/>
 42        protected override void RemoveItem(int index)
 243        {
 244            lock (_lockObject)
 245            {
 246                base.RemoveItem(index);
 247            }
 248        }
 49
 50        /// <inheritdoc cref="ObservableCollection{T}.InsertItem"/>
 51        protected override void InsertItem(int index, T item)
 4052        {
 4053            lock (_lockObject)
 4054            {
 4055                base.InsertItem(index, item);
 4056            }
 4057        }
 58
 59        /// <inheritdoc cref="ObservableCollection{T}.SetItem"/>
 60        protected override void SetItem(int index, T item)
 061        {
 062            lock (_lockObject)
 063            {
 064                base.SetItem(index, item);
 065            }
 066        }
 67
 68        /// <inheritdoc cref="ObservableCollection{T}.MoveItem"/>
 69        protected override void MoveItem(int oldIndex, int newIndex)
 070        {
 071            lock (_lockObject)
 072            {
 073                base.MoveItem(oldIndex, newIndex);
 074            }
 075        }
 76    }
 77}