예제 #1
0
        public IList<PatternStart> RandomizeColoring()
        {
            //original color
            Dictionary<PatternStart, IList<Color>> startToColor = new Dictionary<PatternStart, IList<Color>>();
            //keep track of the active patterns. Will contain new color
            List<PatternStart> active = new List<PatternStart>();

            foreach (var start in _patternStarts)
            {
                IList<Color> colors = EffectsToColors(start.SampleEffect.ColorEffects);
                startToColor[start] = colors;
                OrderedSet<Color> distinct = new OrderedSet<Color>();
                distinct.AddAll(colors);
                IDictionary<Color, Color> oldToNew = OldToNew(startToColor, active);
                Color randBase = distinct.FirstOrDefault(oldToNew.ContainsKey);
                IList<Color> newColors = randBase == default(Color)
                                            ? ColorPicker.PickColors(distinct.Count)
                                            : ColorPicker.PickColors(randBase, distinct.Count);
                IEnumerator<Color> newEnum = newColors.GetEnumerator();
                IEnumerator<Color> oldEnum = distinct.GetEnumerator();
                while(oldEnum.MoveNext())
                {
                    newEnum.MoveNext();
                    if (!oldToNew.ContainsKey(oldEnum.Current))
                    {
                        oldToNew[oldEnum.Current] = newEnum.Current;
                    }
                }
                start.ApplyColors(colors.Select(c=>oldToNew[c]).ToList());
                active.RemoveAll(s => s.EndTime <= start.StartTime);
                active.Add(start);
            }
            return _patternStarts;
        }
예제 #2
0
        /// Summary
        /// Time: 8 min 2 sec
        /// Pattern: Commutative diagram, AAAA
        /// Generalizes two tests "ToArrayTest and GetEnumeratorTest" into one PUT
        public void ToArrayTest([PexAssumeUnderTest] HashSet <int> inputElem)
        {
            OrderedSet <int> set      = new OrderedSet <int>(inputElem);
            List <int>       listElem = new List <int>(inputElem);

            listElem.Sort();
            PexAssert.IsNotNull(set.GetEnumerator());
            CollectionAssert.AreEqual(listElem, set);
        }
예제 #3
0
        public void GetEnumeratorTest()
        {
            OrderedSet <int> set = new OrderedSet <int> {
                10, 23, 1, 89, 34
            };
            List <int> expected = new List <int>();

            foreach (int item in set)
            {
                expected.Add(item);
            }

            Assert.IsNotNull(set.GetEnumerator());
            CollectionAssert.AreEqual(set, expected);
        }
예제 #4
0
        public void OrderedSet_EnumeratesItems_ByInsertionOrder()
        {
            const string firstItem  = "foo";
            const string secondItem = "foo";

            var set = new OrderedSet <string>();

            set.Add(firstItem);
            set.Add(secondItem);

            using (IEnumerator <string> enumerator = set.GetEnumerator())
            {
                enumerator.MoveNext();
                Assert.Equal(firstItem, enumerator.Current);
                enumerator.MoveNext();
                Assert.Equal(secondItem, enumerator.Current);
            }
        }
예제 #5
0
 public void ToArrayTest([PexAssumeUnderTest]HashSet<int> inputElem)
 {
     OrderedSet<int> set = new OrderedSet<int>(inputElem);
     List<int> listElem = new List<int>(inputElem);
     listElem.Sort();
     PexAssert.IsNotNull(set.GetEnumerator());
     CollectionAssert.AreEqual(listElem, set);
 }
예제 #6
0
 public IEnumerator <TEntity> GetEnumerator()
 {
     return(_entities.GetEnumerator());
 }
예제 #7
0
        public void GetEnumeratorTest()
        {
            OrderedSet<int> set = new OrderedSet<int> {10, 23, 1, 89, 34};
            List<int> expected = new List<int>();

            foreach (int item in set) expected.Add(item);

            Assert.IsNotNull(set.GetEnumerator());
            CollectionAssert.AreEqual(set, expected);
        }
 public IEnumerator <UnityEngine.Object> GetEnumerator()
 {
     return(activeObjects.GetEnumerator());
 }