コード例 #1
0
        public void Update_Prefix_WithNullValue_Works(params object[] prefix)
        {
            var sut = new PrefixDictionary <object, object>();

            sut.Add(prefix, 1);
            Assert.That(() => sut.Update(prefix, null), Throws.Nothing);
        }
コード例 #2
0
        public void Update_ExistingPrefix_Works(params object[] prefix)
        {
            var sut = new PrefixDictionary <object, object>();

            sut.Add(prefix, 1);
            Assert.That(() => sut.Update(prefix, 0), Throws.Nothing);
        }
コード例 #3
0
        public void Update_Works(params object[] prefix)
        {
            var sut = new PrefixDictionary <object, object>();

            sut.Add(prefix, 0);
            sut.Update(prefix, 42);
            Assert.That(sut.GetMatches(prefix), Is.EquivalentTo(new[] { 42 }));
        }
コード例 #4
0
        public void GetMatches_Case2()
        {
            var sut = new PrefixDictionary <char, int>();

            sut.Add("", 0);
            sut.Add("PRE", 0);
            sut.Add("PREFIX", 2);
            sut.Update("PRE", 1);

            var actual   = sut.GetMatches("PREF").ToList();
            var expected = new[] { 0, 1 };

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void Update_NullPrefix_Throw()
        {
            var sut = new PrefixDictionary <char, object>();

            Assert.That(() => sut.Update(null, 1), Throws.ArgumentNullException);
        }
コード例 #7
0
        public void Update_NewPrefix_Throw(params object[] prefix)
        {
            var sut = new PrefixDictionary <object, object>();

            Assert.That(() => sut.Update(prefix, 0), Throws.TypeOf <KeyNotFoundException>());
        }