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; }
/// 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); }
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 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); } }
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); }
public IEnumerator <TEntity> GetEnumerator() { return(_entities.GetEnumerator()); }
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()); }