public void GivenAWord_WhenIsHafOfAnotherWord_ShouldRemoveTheEndOfWordFlag() { // Arrange var trie = new MyTrie(); trie.Insert("can"); trie.Insert("cannon"); // Act trie.Remove("can"); // Assert trie.HasWord("can").Should().BeFalse(); trie.HasWord("cannon").Should().BeTrue(); }
public void GivenTwoWords_WhenTheyAreDistinct_ShouldContainsBoth() { // Arrange var word1 = "cat"; var word2 = "dog"; var trie = new MyTrie(); // Act trie.Insert(word1); trie.Insert(word2); // Assert trie.HasWord(word1).Should().BeTrue(); trie.HasWord(word2).Should().BeTrue(); }
public void GivenAnEmptyString_WhenTrieIsEmpty_ShouldReturnFalse() { // Arrange var trie = new MyTrie(); // Assert trie.HasWord("").Should().BeFalse(); }
public void GivenNull_WhenTrieIsEmpty_ShouldReturnFalse() { // Arrange var trie = new MyTrie(); // Assert trie.HasWord(null).Should().BeFalse(); }
public void GivenAEmptyTrie_WhenTryToFindAWord_ShouldReturnFalse() { // Arrange var trie = new MyTrie(); // Assert trie.HasWord("test").Should().BeFalse(); }
public void GivenAWord_WhenTrieHasThisOne_ShouldRemoveIt() { // Arrange var trie = new MyTrie(); trie.Insert("cat"); // Act trie.Remove("cat"); // Assert trie.HasWord("cat").Should().BeFalse(); }
public void GivenAWord_WhenTrieIsEmpty_ShouldAddIt() { // Arrange var word = "test"; var trie = new MyTrie(); // Act trie.Insert(word); // Assert trie.HasWord(word).Should().BeTrue(); }
public void GivenATrie_WhenTryToFindAInexistentWord_ShouldReturnFalse() { // Arrange var word = "cat"; var search = "dog"; var trie = new MyTrie(); // Act trie.Insert(word); // Assert trie.HasWord(search).Should().BeFalse(); }
public void GivenAWord_WhenIsPartOfAnotherWord_ShouldReturnFalse() { // Arrange var word = "Canada"; var search = "Can"; var trie = new MyTrie(); // Act trie.Insert(word); // Assert trie.HasWord(search).Should().BeFalse(); }
public void GivenAWord_WhenTryToAddTwice_ShouldContainOne() { // Arrange var word = "test"; var trie = new MyTrie(); // Act trie.Insert(word); trie.Insert(word); // Assert trie.HasWord(word).Should().BeTrue(); }