public void Add_Works(params object[] prefix) { var sut = new PrefixDictionary <object, object>(); sut.Add(prefix, 42); Assert.That(sut.GetMatches(prefix), Is.EquivalentTo(new[] { 42 })); }
public void Scenario1() { var sut = new PrefixDictionary <char, int>(); Assert.That(sut.Remove("P"), Is.False); Assert.That(() => sut.Add("P", 0), Throws.Nothing); Assert.That(sut.Remove("P"), Is.True); Assert.That(() => sut.Add("P", 0), Throws.Nothing); Assert.That(sut.Remove("P"), Is.True); Assert.That(() => sut.Update("P", 0), Throws.TypeOf <KeyNotFoundException>()); Assert.That(() => sut.Add("P", 0), Throws.Nothing); Assert.That(() => sut.Add("PREFIX", 1), Throws.Nothing); Assert.That(sut.GetMatches("PREFIX"), Is.EquivalentTo(new[] { 0, 1 })); Assert.That(sut.Remove("P"), Is.True); Assert.That(sut.GetMatches("PREFIX"), Is.EquivalentTo(new[] { 1 })); Assert.That(sut.Remove("PREFIX"), Is.True); Assert.That(sut.GetMatches("PREFIX"), Is.Empty); }
public void GetMatches_Case5() { var sut = new PrefixDictionary <char, int>(); sut.Add("PRA", 0); sut.Add("PRE", 1); sut.Add("PRI", 2); var actual = sut.GetMatches("PREFIX").ToList(); var expected = new[] { 1 }; Assert.AreEqual(expected, actual); }
public void GetMatches_Case6() { var sut = new PrefixDictionary <char, int>(); sut.Add("", 0); sut.Add("P", 1); sut.Add("PR", 2); sut.Add("PRE", 3); sut.Add("PREF", 4); sut.Add("PREFI", 5); sut.Add("PREFIX", 6); var actual = sut.GetMatches("PREFIX").ToList(); var expected = new[] { 0, 1, 2, 3, 4, 5, 6 }; Assert.AreEqual(expected, actual); }
public void GetMatches_ModificationInEnumeration_Throw() { var sut = new PrefixDictionary <char, int>(); sut.Add("", 0); sut.Add("P", 1); sut.Add("PR", 2); sut.Add("PRE", 3); sut.Add("PREF", 4); sut.Add("PREFI", 5); sut.Add("PREFIX", 6); Assert.That(() => { foreach (var match in sut.GetMatches("PREFIX")) { sut.Add("TEST", 0); } }, Throws.InvalidOperationException); }
public void GetMatches_NullEntry_Throw() { var sut = new PrefixDictionary <char, object>(); Assert.That(() => sut.GetMatches(null), Throws.ArgumentNullException); }