File tree 2 files changed +13
-4
lines changed
UnitTest/DataStructuresTests
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -184,11 +184,11 @@ public int GetPreviousPrime(int number)
184
184
}
185
185
186
186
/// <summary>
187
- /// Returns the list of primes
187
+ /// Returns the read-only IList of primes
188
188
/// </summary>
189
- public List < int > GetAll
189
+ public IList < int > GetAll
190
190
{
191
- get { return _primes ; }
191
+ get { return _primes . AsReadOnly ( ) ; }
192
192
}
193
193
194
194
/// <summary>
Original file line number Diff line number Diff line change 1
- using DataStructures . Common ;
1
+ using System ;
2
+ using DataStructures . Common ;
2
3
using Xunit ;
3
4
4
5
namespace UnitTest . DataStructuresTests
@@ -11,5 +12,13 @@ public void DoTest()
11
12
var instance = PrimesList . Instance ;
12
13
Assert . Equal ( 10000 , instance . Count ) ;
13
14
}
15
+
16
+ [ Fact ]
17
+ public void PrimesListIsReadOnly ( )
18
+ {
19
+ var instance = PrimesList . Instance ;
20
+ NotSupportedException ex = Assert . Throws < NotSupportedException > ( ( ) => instance . GetAll [ 0 ] = - 1 ) ;
21
+ Assert . Equal ( "Collection is read-only." , ex . Message ) ;
22
+ }
14
23
}
15
24
}
You can’t perform that action at this time.
0 commit comments