예제 #1
0
        public void Reset_ShouldEmptyTrie()
        {
            //Arrange
            var trie = new Domain.Models.DataStructure.Trie();

            trie.Insert(new Location
            {
                Name                 = "Amos",
                Latitude             = -43.0987,
                Longitude            = 127.6782,
                Country              = "CA",
                AdministrativeRegion = "10",
                Population           = 25000
            });

            //Act
            trie.Reset();

            //Assert
            var isEmpty = trie.IsEmpty();

            isEmpty.ShouldSatisfyAllConditions(
                () => isEmpty.ShouldBeTrue()
                );
        }
예제 #2
0
        public void IsEmpty_ShouldReturnTrue_WhenEmpty()
        {
            //Arrange
            var trie = new Domain.Models.DataStructure.Trie();

            //Act
            var result = trie.IsEmpty();

            //Assert
            result.ShouldSatisfyAllConditions(
                () => result.ShouldBeTrue()
                );
        }
예제 #3
0
        public void GetSuggestionsForPrefix_ShouldReturnTwoLocations_ForSameName()
        {
            //Arrange
            var trie   = new Domain.Models.DataStructure.Trie();
            var values = new List <Location>
            {
                new Location
                {
                    Name                 = "Carleton",
                    Latitude             = -43.0987,
                    Longitude            = 127.6782,
                    Country              = "CA",
                    AdministrativeRegion = "10",
                    Population           = 25000
                },
                new Location
                {
                    Name                 = "Carleton",
                    Latitude             = -43.0987,
                    Longitude            = 127.6782,
                    Country              = "CA",
                    AdministrativeRegion = "10",
                    Population           = 25000
                }
            };

            foreach (var value in values)
            {
                trie.Insert(value);
            }

            //Act
            var results = trie.GetSuggestionsForPrefix("Car").ToList();

            //Assert
            results.ShouldSatisfyAllConditions(
                () => results.Count.ShouldBe(2)
                );
        }