Ejemplo n.º 1
0
        public void TestCount()
        {
            var combined_list = new CombinedList<int>(CreateOddSequence(), CreateEvenSequence());

            Assert.AreEqual(CreateSequence().Count, combined_list.Count);
            Assert.AreEqual(10, combined_list.Count);
        }
Ejemplo n.º 2
0
        [Test()] public void TestCount()
        {
            var combined_list = new CombinedList <int>(CreateOddSequence(), CreateEvenSequence());

            Assert.AreEqual(CreateSequence().Count, combined_list.Count);
            Assert.AreEqual(10, combined_list.Count);
        }
Ejemplo n.º 3
0
        private static bool TryExpandCommandAliases(IReadOnlyDictionary <string, IReadOnlyList <string> > aliases, IReadOnlyList <string> inputTokens, out IReadOnlyList <string> expandedTokens)
        {
            bool             expansionOccurred = false;
            HashSet <string> seenAliases       = new HashSet <string>();

            expandedTokens = new List <string>(inputTokens);

            do
            {
                string candidateAliasName = expandedTokens[0];

                if (aliases.TryGetValue(candidateAliasName, out IReadOnlyList <string> aliasExpansion))
                {
                    if (!seenAliases.Add(candidateAliasName))
                    {
                        // a cycle has occurred.... not allowed.
                        expandedTokens = null;
                        return(false);
                    }

                    // The expansion is the combination of the aliasExpansion (expands the 0th token of the previously expandedTokens)
                    //  and the rest of the previously expandedTokens
                    expandedTokens    = new CombinedList <string>(aliasExpansion, expandedTokens.ToList().GetRange(1, expandedTokens.Count - 1));
                    expansionOccurred = true;
                }
                else
                {
                    expansionOccurred = false;
                }
            } while (expansionOccurred);

            return(true);
        }
Ejemplo n.º 4
0
        public void TestIsReadOnly()
        {
            var combined_list = new CombinedList<int>(CreateOddSequence(), CreateEvenSequence());

            Assert.IsFalse(combined_list.IsReadOnly);

            Assert.IsTrue( (new CombinedList<int>(CreateSequence(), CreateEvenSequence())).IsReadOnly );
        }
Ejemplo n.º 5
0
        [Test()] public void TestIsReadOnly()
        {
            var combined_list = new CombinedList <int>(CreateOddSequence(), CreateEvenSequence());

            Assert.IsFalse(combined_list.IsReadOnly);

            Assert.IsTrue((new CombinedList <int>(CreateSequence(), CreateEvenSequence())).IsReadOnly);
        }
Ejemplo n.º 6
0
        public void TestIndex()
        {
            var combined_list = new CombinedList<int>(CreateOddSequence(), CreateEvenSequence());

            var list = CreateSequence();

            for (int i = 0; i < combined_list.Count; i++)
                Assert.AreEqual(list[i], combined_list[i]);
        }
Ejemplo n.º 7
0
        /// <summary>Create a CombinedRatings object from to existing IRatings objects</summary>
        /// <param name="ratings1">the first data set</param>
        /// <param name="ratings2">the second data set</param>
        public CombinedRatings(IRatings ratings1, IRatings ratings2)
        {
            Users = new CombinedList<int>(ratings1.Users, ratings2.Users);
            Items = new CombinedList<int>(ratings1.Items, ratings2.Items);
            Values = new CombinedList<double>(ratings1, ratings2);

            MaxUserID = Math.Max(ratings1.MaxUserID, ratings2.MaxUserID);
            MaxItemID = Math.Max(ratings1.MaxItemID, ratings2.MaxItemID);
        }
Ejemplo n.º 8
0
        /// <summary>Create a CombinedRatings object from to existing IRatings objects</summary>
        /// <param name="ratings1">the first data set</param>
        /// <param name="ratings2">the second data set</param>
        public CombinedRatings(IRatings ratings1, IRatings ratings2)
        {
            Users  = new CombinedList <int>(ratings1.Users, ratings2.Users);
            Items  = new CombinedList <int>(ratings1.Items, ratings2.Items);
            Values = new CombinedList <double>(ratings1, ratings2);

            MaxUserID = Math.Max(ratings1.MaxUserID, ratings2.MaxUserID);
            MaxItemID = Math.Max(ratings1.MaxItemID, ratings2.MaxItemID);
        }
Ejemplo n.º 9
0
		/// <summary>Create a CombinedRatings object from to existing IRatings objects</summary>
		/// <param name="ratings1">the first data set</param>
		/// <param name="ratings2">the second data set</param>
		public CombinedRatings(IRatings ratings1, IRatings ratings2)
		{
			Users = new CombinedList<int>(ratings1.Users, ratings2.Users);
			Items = new CombinedList<int>(ratings1.Items, ratings2.Items);
			Values = new CombinedList<float>(ratings1, ratings2);

			Scale = new RatingScale(ratings1.Scale, ratings2.Scale);
			MaxUserID = Math.Max(ratings1.MaxUserID, ratings2.MaxUserID);
			MaxItemID = Math.Max(ratings1.MaxItemID, ratings2.MaxItemID);
		}
Ejemplo n.º 10
0
        public void TestContains()
        {
            var combined_list = new CombinedList<int>(CreateOddSequence(), CreateEvenSequence());

            foreach (int num in CreateEvenSequence())
                Assert.IsTrue(combined_list.Contains(num));

            foreach (int num in CreateOddSequence())
                Assert.IsTrue(combined_list.Contains(num));
        }
Ejemplo n.º 11
0
        /// <summary>Create a CombinedRatings object from to existing IRatings objects</summary>
        /// <param name="ratings1">the first data set</param>
        /// <param name="ratings2">the second data set</param>
        public CombinedRatings(IRatings ratings1, IRatings ratings2)
        {
            Users  = new CombinedList <int>(ratings1.Users, ratings2.Users);
            Items  = new CombinedList <int>(ratings1.Items, ratings2.Items);
            Values = new CombinedList <float>(ratings1, ratings2);

            Scale     = new RatingScale(ratings1.Scale, ratings2.Scale);
            MaxUserID = Math.Max(ratings1.MaxUserID, ratings2.MaxUserID);
            MaxItemID = Math.Max(ratings1.MaxItemID, ratings2.MaxItemID);
        }
Ejemplo n.º 12
0
        [Test()] public void TestIndex()
        {
            var combined_list = new CombinedList <int>(CreateOddSequence(), CreateEvenSequence());

            var list = CreateSequence();

            for (int i = 0; i < combined_list.Count; i++)
            {
                Assert.AreEqual(list[i], combined_list[i]);
            }
        }
Ejemplo n.º 13
0
        public void TestRemoveAt()
        {
            var combined_list = new CombinedList<int>(CreateOddSequence(), CreateEvenSequence());

            Assert.AreEqual(10, combined_list.Count);

            combined_list.RemoveAt(0);
            Assert.AreEqual(9, combined_list.Count);
            Assert.AreEqual(3, combined_list[0]);

            combined_list.RemoveAt(6);
            Assert.AreEqual(8, combined_list.Count);
            Assert.AreEqual(8, combined_list[6]);
        }
Ejemplo n.º 14
0
        [Test()] public void TestRemoveAt()
        {
            var combined_list = new CombinedList <int>(CreateOddSequence(), CreateEvenSequence());

            Assert.AreEqual(10, combined_list.Count);

            combined_list.RemoveAt(0);
            Assert.AreEqual(9, combined_list.Count);
            Assert.AreEqual(3, combined_list[0]);

            combined_list.RemoveAt(6);
            Assert.AreEqual(8, combined_list.Count);
            Assert.AreEqual(8, combined_list[6]);
        }
Ejemplo n.º 15
0
        [Test()] public void TestContains()
        {
            var combined_list = new CombinedList <int>(CreateOddSequence(), CreateEvenSequence());

            foreach (int num in CreateEvenSequence())
            {
                Assert.IsTrue(combined_list.Contains(num));
            }

            foreach (int num in CreateOddSequence())
            {
                Assert.IsTrue(combined_list.Contains(num));
            }
        }
Ejemplo n.º 16
0
        public void VerifyCombinedListCombinesCorrectly(IReadOnlyList <int> listOne, IReadOnlyList <int> listTwo)
        {
            CombinedList <int> combined = new CombinedList <int>(listOne, listTwo);

            List <int> manuallyAppended = new List <int>();

            manuallyAppended.AddRange(listOne);
            manuallyAppended.AddRange(listTwo);

            Assert.Equal(combined.Count, manuallyAppended.Count);

            int enumerationCount = 0;

            foreach (int value in combined)
            {
                enumerationCount++;
            }

            Assert.Equal(enumerationCount, combined.Count);
        }