Exemplo n.º 1
0
        public void TesGetItems()
        {
            // Arrange
            var searchDictionary = new SearchDictionary <string>();
            var tag1             = Guid.NewGuid().ToString();
            var tag2             = Guid.NewGuid().ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> ranges1 = from value in Enumerable.Range(1, 10)
                                           select value.ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> ranges2 = from value in Enumerable.Range(1, 10)
                                           select value.ToString();

            //Act
            searchDictionary.Add(ranges1, tag1); //Add 10 strings using the tag1
            searchDictionary.Add(ranges2, tag2); //Add 10 strings using the tag2

            //This will execute the method internal IEnumerable<V> ByTag(string tag)
            var ienumTags = searchDictionary.ByTag(tag1);

            var tags = searchDictionary.GetTags("5");       //This will return 2 tags

            var weights = searchDictionary.GetWeights("5"); //This will return 2 weights

            //Assert
            //This will validate that the method ByTag returns the 10 strings inserted
            Assert.AreEqual(ienumTags.Count(), 10);

            //This will validate that the dictionary contains the value "6"
            Assert.IsTrue(searchDictionary.Contains("6"));//This will execute the method bool Contains(V a)

            //Check that the two different tags are returned for the "5" value
            Assert.AreEqual(tags.Count(), 2);

            //Check that the two different weights are returned for the "5" value
            Assert.AreEqual(weights.Count(), 2);
        }