public void TestCopyTo_Copies() { StringAdapter list = new StringAdapter("Hello"); char[] output = new char[list.Count]; list.CopyTo(output, 0); Assert.AreEqual("Hello", new String(output), "The values were not copied."); }
public void TestCopyTo_Copies_StartingAtArrayIndex() { StringAdapter list = new StringAdapter("Hello"); char[] output = new char[list.Count + 2]; output[0] = 'a'; output[1] = 'a'; list.CopyTo(output, 2); Assert.AreEqual("aaHello", new String(output), "The values were not copied."); }
private IAdapter GetAdapter(XElement element) { string adapterType = GetAttribute(element, "Type"); string adapterName = GetAttribute(element, "Name"); IAdapter adapter = null; var channelElement = element.Element("Channel"); if (channelElement == null) { throw new ElementNotFoundException("Channel elemnt not found."); } var interpreterElement = element.Element("Interpreter"); if (interpreterElement == null) { throw new ElementNotFoundException("Interpreter elemnt not found."); } if (adapterType == "ByteArrayAdapter") { IChannel<byte[]> channel = (IChannel<byte[]>)GetChannel(channelElement); IInterpreter<byte[]> interpreter = (IInterpreter<byte[]>)GetInterpreter(interpreterElement); adapter = new ByteArrayAdapter(adapterName, channel, interpreter); } else if (adapterType == "StringAdapter") { IChannel<string> channel = (IChannel<string>)GetChannel(channelElement); IInterpreter<string> interpreter = (IInterpreter<string>)GetInterpreter(interpreterElement); adapter = new StringAdapter(adapterName, channel, interpreter); } else { throw new UnknownElementException("Unknown adapter type:" + adapterType); } _adapterObjects[_currentAdapterName].Add(adapter.Name, adapter); return adapter; }
public void TestCtor_SetsUnderlyingString() { const string value = "Hello"; StringAdapter list = new StringAdapter(value); Assert.AreSame(value, list.Value, "The backing field was not set."); Assert.AreEqual(value.Length, list.Count, "The counts did not match."); Assert.IsTrue(((ICollection<char>)list).IsReadOnly, "The list should have been read-only."); }
public void TestContains_ValueDoesNotExists_ReturnsFalse() { StringAdapter list = new StringAdapter("Hello"); bool result = list.Contains('r'); Assert.IsFalse(result, "The character should not have been found."); }
public void TestContains_ValueExists_ReturnsTrue() { StringAdapter list = new StringAdapter("Hello"); bool result = list.Contains('e'); Assert.IsTrue(result, "The character should have been found."); }
public void TestAdd_Throws() { IList<char> list = new StringAdapter("Hello"); list.Add('a'); }
public void TestClear_Throws() { IList<char> list = new StringAdapter("Hello"); list.Clear(); }
public void TestInsert_Throws() { IList<char> list = new StringAdapter("Hello"); list.Insert(0, 'a'); }
public void TestRemove_Throws() { IList<char> list = new StringAdapter("Hello"); list.Remove('e'); }
public void TestIndexOf_ValueNotFound_ReturnsNegativeOne() { StringAdapter list = new StringAdapter("Hello"); int index = list.IndexOf('r'); Assert.AreEqual(-1, index, "The wrong index was returned."); }
public void TestIndexOf_ValueFound_ReturnsFirst() { StringAdapter list = new StringAdapter("Hello, Yellow"); int index = list.IndexOf('e'); Assert.AreEqual(1, index, "The wrong index was returned."); }
public void TestIndexer_Setter_Throws() { string value = "Hello"; StringAdapter list = new StringAdapter(value); list[0] = 'a'; }
public void TestIndexer_Getter_ReturnsCharacter() { string value = "Hello"; StringAdapter list = new StringAdapter(value); Assert.AreEqual(list[2], value[2], "The index returned the wrong value."); }
public void TestGetEnumerable_Implicit_StillEnumerates() { IEnumerable list = new StringAdapter("Hello"); IEnumerator enumerator = list.GetEnumerator(); moveAndCheck(enumerator, 'H'); moveAndCheck(enumerator, 'e'); moveAndCheck(enumerator, 'l'); moveAndCheck(enumerator, 'l'); moveAndCheck(enumerator, 'o'); Assert.IsFalse(enumerator.MoveNext(), "There should not have been any more items."); }