I am writing a doubly linked list using the TDD approach. This type of collection is not thread safe. To implement the ICollection interface, my list class must have several public properties (including IsSynchronized and SyncRoot, which are used to provide a thread-safe way to use the collection). The code for these two properties is pretty simple:
public bool IsSynchronized { get { return false; } } private readonly object _syncRoot = new object(); public object SyncRoot { get { return _syncRoot; } }
The question is how to write the correct unit test for it. This test should verify proper use and misuse.
my list class should have several public properties (including IsSynchronized and SyncRoot
. .NET 1 . , . , . .NET 2.0. ICollection, ICollection<T>. , , IEnumerable, , , , . , .
ICollection<T>
, ICollection < > . , , O (n) . , O (1). .NET LinkedList < > , , .
, . SyncRoot , -, , /, - . ( , , .)
SyncRoot
, , , ( IsSynchronized return false); , .
IsSynchronized
false
, , ICollection SyncRoot ( null). - .
ICollection
null
unit test , SyncRoot null.
Source: https://habr.com/ru/post/1787324/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1787319/upload-images-to-remote-servers-php&usg=ALkJrhjkHeVAb3YXhMJxrILEw5xksVxYaQDisplay a static image in Google Map in BlackBerry 5.0 - imageΠΡΠΎΠ²Π΅ΡΠΊΠ° ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΡΡΠΈ ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΡΠΎΡΠΌΡ JQuery Π² ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΠ΅- jqueryΠΠΎΠΆΠ½ΠΎ Π»ΠΈ ΠΊΠΎΠ½ΡΡΠΎΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΎΠ±ΡΠ΅ΠΌ ΠΌΠ΅Π΄ΠΈΠ°-ΠΏΠ»Π΅Π΅ΡΠ° ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ Π² Android ΠΎΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π΄Π»Ρ Android - androidHTTPclient POST with problematic website - javaSmart Pointers, Forward Declaration and C4150 - c ++Closing attribute values ββin HTML and CSS - htmlBit order in bit streams - javaVBA MS Word Font Color - vbaUIAlertview with vertical buttons - iphoneAll Articles