示例#1
0
        public void GivenEmptyDictionaryNode_WhenFindCalled_ShouldReturnNull()
        {
            var dictionary = new TreeBasedDictionary();
            var aNode      = dictionary.Find("a");

            Assert.That(aNode, Is.Null);
        }
示例#2
0
        public void GivenDictionaryWithNodeAdded_WhenFindCalled_ShouldReturnNotNull()
        {
            var dictionary = new TreeBasedDictionary();

            dictionary.Add("a");
            var aNode = dictionary.Find("a");

            Assert.That(aNode, Is.Not.Null);
        }
示例#3
0
        public void GivenDictionaryWithNodeAddedForWord_WhenWordsCalled_ShouldReturnTheWord()
        {
            var dictionary = new TreeBasedDictionary();

            dictionary.Add("an");
            var words = dictionary.Words();

            Assert.That(words, Is.EquivalentTo(new [] { "an" }));
        }
示例#4
0
        public void GivenDictionaryWithBluesAndBlues_WhenWordsCalled_ShouldReturnBothWords()
        {
            var dictionary = new TreeBasedDictionary();

            dictionary.Add("blues");
            dictionary.Add("blue");
            var words = dictionary.Words();

            Assert.That(words, Is.EquivalentTo(new[] { "blue", "blues" }));
        }
示例#5
0
        public void GivenDictionaryWithNodeAddedForTwoCharWord_WhenFindCalledOnceOnEachChar_ShouldReturnSameNodeAsFindCalledOnceOnWholeWord()
        {
            var dictionary = new TreeBasedDictionary();

            dictionary.Add("an");
            var anNodeReachedBySingleCall = dictionary.Find("an");
            var anNodeReachedyTwoCalls    = dictionary.Find("a").FindNodeOrNull('n');

            Assert.That(anNodeReachedBySingleCall, Is.EqualTo(anNodeReachedyTwoCalls));
        }
示例#6
0
        public void GivenDictionaryWithGrayAndGreen_WhenWordsCalledBeginningWithGre_ShouldReturnOnly_en()
        {
            var dictionary = new TreeBasedDictionary();

            dictionary.Add("gray");
            dictionary.Add("green");
            var node  = dictionary.Find("gre");
            var words = node.Words(string.Empty);

            Assert.That(words, Is.EquivalentTo(new[] { "en" }));
        }