|
| 1 | +//using nanoFramework.TestFramework; |
| 2 | +//using System; |
| 3 | +//using System.Collections; |
| 4 | + |
| 5 | +//namespace GenericCollections |
| 6 | +//{ |
| 7 | +// public class CollectionTestBase |
| 8 | +// { |
| 9 | +// protected static readonly int[] s_intArray = new[] { -4, 5, -2, 3, 1, 2, -1, -3, 0, 4, -5, 3, 3 }; |
| 10 | +// protected static readonly int[] s_excludedFromIntArray = new int[] { 100, -34, 42, int.MaxValue, int.MinValue }; |
| 11 | + |
| 12 | +// [Flags] |
| 13 | +// protected enum IListApi |
| 14 | +// { |
| 15 | +// None = 0, |
| 16 | +// IndexerGet = 0x1, |
| 17 | +// IndexerSet = 0x2, |
| 18 | +// Count = 0x4, |
| 19 | +// IsReadOnly = 0x8, |
| 20 | +// Clear = 0x10, |
| 21 | +// Contains = 0x20, |
| 22 | +// CopyTo = 0x40, |
| 23 | +// GetEnumeratorGeneric = 0x80, |
| 24 | +// IndexOf = 0x100, |
| 25 | +// Insert = 0x200, |
| 26 | +// RemoveAt = 0x400, |
| 27 | +// GetEnumerator = 0x800, |
| 28 | +// End |
| 29 | +// } |
| 30 | + |
| 31 | +// protected class CallTrackingIList<T> : IList<T> |
| 32 | +// { |
| 33 | +// private IListApi _expectedApiCalls; |
| 34 | +// private IListApi _calledMembers; |
| 35 | + |
| 36 | +// public CallTrackingIList(IListApi expectedApiCalls) |
| 37 | +// { |
| 38 | +// _expectedApiCalls = expectedApiCalls; |
| 39 | +// } |
| 40 | + |
| 41 | +// public void AssertAllMembersCalled() |
| 42 | +// { |
| 43 | +// if (_expectedApiCalls != _calledMembers) |
| 44 | +// { |
| 45 | +// for (IListApi i = (IListApi)1; i < IListApi.End; i = (IListApi)((int)i << 1)) |
| 46 | +// { |
| 47 | +// Assert.Equal(_expectedApiCalls & i, _calledMembers & i); |
| 48 | +// } |
| 49 | +// } |
| 50 | +// } |
| 51 | + |
| 52 | +// public T this[int index] |
| 53 | +// { |
| 54 | +// get |
| 55 | +// { |
| 56 | +// _calledMembers |= IListApi.IndexerGet; |
| 57 | +// return default(T); |
| 58 | +// } |
| 59 | +// set |
| 60 | +// { |
| 61 | +// _calledMembers |= IListApi.IndexerSet; |
| 62 | +// } |
| 63 | +// } |
| 64 | + |
| 65 | +// public int Count |
| 66 | +// { |
| 67 | +// get |
| 68 | +// { |
| 69 | +// _calledMembers |= IListApi.Count; |
| 70 | +// return 1; |
| 71 | +// } |
| 72 | +// } |
| 73 | + |
| 74 | +// public bool IsReadOnly |
| 75 | +// { |
| 76 | +// get |
| 77 | +// { |
| 78 | +// _calledMembers |= IListApi.IsReadOnly; |
| 79 | +// return false; |
| 80 | +// } |
| 81 | +// } |
| 82 | + |
| 83 | +// public void Add(T item) |
| 84 | +// { |
| 85 | +// throw new NotImplementedException(); |
| 86 | +// } |
| 87 | + |
| 88 | +// public void Clear() |
| 89 | +// { |
| 90 | +// _calledMembers |= IListApi.Clear; |
| 91 | +// } |
| 92 | + |
| 93 | +// public bool Contains(T item) |
| 94 | +// { |
| 95 | +// _calledMembers |= IListApi.Contains; |
| 96 | +// return false; |
| 97 | +// } |
| 98 | + |
| 99 | +// public void CopyTo(T[] array, int arrayIndex) |
| 100 | +// { |
| 101 | +// _calledMembers |= IListApi.CopyTo; |
| 102 | +// } |
| 103 | + |
| 104 | +// public IEnumerator<T> GetEnumerator() |
| 105 | +// { |
| 106 | +// _calledMembers |= IListApi.GetEnumeratorGeneric; |
| 107 | +// return null; |
| 108 | +// } |
| 109 | + |
| 110 | +// public int IndexOf(T item) |
| 111 | +// { |
| 112 | +// _calledMembers |= IListApi.IndexOf; |
| 113 | +// return -1; |
| 114 | +// } |
| 115 | + |
| 116 | +// public void Insert(int index, T item) |
| 117 | +// { |
| 118 | +// _calledMembers |= IListApi.Insert; |
| 119 | +// } |
| 120 | + |
| 121 | +// public bool Remove(T item) |
| 122 | +// { |
| 123 | +// throw new NotImplementedException(); |
| 124 | +// } |
| 125 | + |
| 126 | +// public void RemoveAt(int index) |
| 127 | +// { |
| 128 | +// _calledMembers |= IListApi.RemoveAt; |
| 129 | +// } |
| 130 | + |
| 131 | +// IEnumerator IEnumerable.GetEnumerator() |
| 132 | +// { |
| 133 | +// _calledMembers |= IListApi.GetEnumerator; |
| 134 | +// return null; |
| 135 | +// } |
| 136 | +// } |
| 137 | +// } |
| 138 | +//} |
0 commit comments