-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
ArrayList.IList.Tests.cs
97 lines (78 loc) · 4.31 KB
/
ArrayList.IList.Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using Xunit;
namespace System.Collections.Tests
{
public class ArrayListBasicTests : ArrayListIListTestBase
{
protected override bool SupportsSerialization => true;
protected override IList NonGenericIListFactory() => new ArrayList();
}
public class ArrayListSynchronizedTests : ArrayListIListTestBase
{
protected override bool ExpectedIsSynchronized => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.Synchronized(Helpers.CreateIntArrayList(count));
}
public class ArrayListSynchronizedILstTests : ArrayListIListTestBase
{
protected override bool ExpectedIsSynchronized => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.Synchronized((IList)Helpers.CreateIntArrayList(count));
}
public class ArrayListFixedSizeTests : ArrayListIListTestBase
{
protected override bool ExpectedFixedSize => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.FixedSize(Helpers.CreateIntArrayList(count));
}
public class ArrayListFixedIListSizeTests : ArrayListIListTestBase
{
protected override bool ExpectedFixedSize => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.FixedSize((IList)Helpers.CreateIntArrayList(count));
}
public class ArrayListReadOnlyTests : ArrayListIListTestBase
{
protected override bool ExpectedFixedSize => true;
protected override bool IsReadOnly => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.ReadOnly(Helpers.CreateIntArrayList(count));
}
public class ArrayListReadOnlyIListTests : ArrayListIListTestBase
{
protected override bool ExpectedFixedSize => true;
protected override bool IsReadOnly => true;
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.ReadOnly((IList)Helpers.CreateIntArrayList(count));
}
public class ArrayListAdapterTests : ArrayListIListTestBase
{
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => ArrayList.Adapter(Helpers.CreateIntArrayList(count));
}
public class ArrayListRangeTests : ArrayListIListTestBase
{
protected override IList NonGenericIListFactory() => NonGenericIListFactory(0);
protected override IList NonGenericIListFactory(int count) => Helpers.CreateIntArrayList(count).GetRange(0, count);
}
public abstract class ArrayListIListTestBase : IList_NonGeneric_Tests
{
protected override bool Enumerator_Current_UndefinedOperation_Throws => true;
// ArrayList supports serialization, but its nested types don't
protected override bool SupportsSerialization => false;
protected override Type ICollection_NonGeneric_CopyTo_ArrayOfEnumType_ThrowType => typeof(InvalidCastException);
protected override Type ICollection_NonGeneric_CopyTo_ArrayOfIncorrectReferenceType_ThrowType => typeof(InvalidCastException);
protected override Type ICollection_NonGeneric_CopyTo_ArrayOfIncorrectValueType_ThrowType => typeof(InvalidCastException);
protected override Type ICollection_NonGeneric_CopyTo_NonZeroLowerBound_ThrowType => typeof(ArgumentOutOfRangeException);
protected override object CreateT(int seed)
{
int stringLength = seed % 10 + 5;
Random rand = new Random(seed);
byte[] bytes = new byte[stringLength];
rand.NextBytes(bytes);
return Convert.ToBase64String(bytes);
}
}
}