forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdictionarytest.cs
More file actions
106 lines (77 loc) · 2.77 KB
/
Copy pathdictionarytest.cs
File metadata and controls
106 lines (77 loc) · 2.77 KB
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
98
99
100
101
102
103
104
105
106
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Python.Test
{
/// <summary>
/// Supports units tests for dictionary __contains__ and __len__
/// </summary>
public class PublicDictionaryTest
{
public IDictionary<string, int> items;
public PublicDictionaryTest()
{
items = new int[5] { 0, 1, 2, 3, 4 }
.ToDictionary(k => k.ToString(), v => v);
}
}
public class ProtectedDictionaryTest
{
protected IDictionary<string, int> items;
public ProtectedDictionaryTest()
{
items = new int[5] { 0, 1, 2, 3, 4 }
.ToDictionary(k => k.ToString(), v => v);
}
}
public class InternalDictionaryTest
{
internal IDictionary<string, int> items;
public InternalDictionaryTest()
{
items = new int[5] { 0, 1, 2, 3, 4 }
.ToDictionary(k => k.ToString(), v => v);
}
}
public class PrivateDictionaryTest
{
private IDictionary<string, int> items;
public PrivateDictionaryTest()
{
items = new int[5] { 0, 1, 2, 3, 4 }
.ToDictionary(k => k.ToString(), v => v);
}
}
public class InheritedDictionaryTest : IDictionary<string, int>
{
private readonly IDictionary<string, int> items;
public InheritedDictionaryTest()
{
items = new int[5] { 0, 1, 2, 3, 4 }
.ToDictionary(k => k.ToString(), v => v);
}
public int this[string key]
{
get { return items[key]; }
set { items[key] = value; }
}
public ICollection<string> Keys => items.Keys;
public ICollection<int> Values => items.Values;
public int Count => items.Count;
public bool IsReadOnly => false;
public void Add(string key, int value) => items.Add(key, value);
public void Add(KeyValuePair<string, int> item) => items.Add(item);
public void Clear() => items.Clear();
public bool Contains(KeyValuePair<string, int> item) => items.Contains(item);
public bool ContainsKey(string key) => items.ContainsKey(key);
public void CopyTo(KeyValuePair<string, int>[] array, int arrayIndex)
{
items.CopyTo(array, arrayIndex);
}
public IEnumerator<KeyValuePair<string, int>> GetEnumerator() => items.GetEnumerator();
public bool Remove(string key) => items.Remove(key);
public bool Remove(KeyValuePair<string, int> item) => items.Remove(item);
public bool TryGetValue(string key, out int value) => items.TryGetValue(key, out value);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}