示例#1
0
            public void ShuffledAndRepeated()
            {
                var queue = new MediaQueue();

                var tracks = new[]
                {
                    new MediaFile(),
                    new MediaFile(),
                };

                queue.AddRange(tracks);
                queue.ToggleShuffle();
                queue.ToggleRepeat(RepeatType.RepeatOne);

                IList <NotifyCollectionChangedEventArgs> collectionChangedEvents = new List <NotifyCollectionChangedEventArgs>();
                IList <PropertyChangedEventArgs>         propertyChangedEvents   = new List <PropertyChangedEventArgs>();

                queue.CollectionChanged += (sender, e) => collectionChangedEvents.Add(e);
                queue.PropertyChanged   += (sender, e) => propertyChangedEvents.Add(e);

                queue.Clear();

                Assert.AreEqual(0, queue.Count);
                Assert.AreEqual(null, queue.Current);
                Assert.AreEqual(-1, queue.Index);
                Assert.AreEqual(RepeatType.RepeatOne, queue.Repeat);
                Assert.AreEqual(RepeatType.None, queue.Shuffle);

                Assert.AreEqual(1, propertyChangedEvents.Where(e => e.PropertyName == "Current").Count());
                Assert.AreEqual(1, propertyChangedEvents.Where(e => e.PropertyName == "Index").Count());
                Assert.AreEqual(1, propertyChangedEvents.Where(e => e.PropertyName == "Count").Count());
                Assert.AreEqual(1, propertyChangedEvents.Where(e => e.PropertyName == "Shuffle").Count());
                Assert.AreEqual(4, propertyChangedEvents.Count);
                Assert.AreEqual(1, collectionChangedEvents.Where(e => e.NewItems == null && e.OldItems == null).Count());
                Assert.AreEqual(1, collectionChangedEvents.Count);
            }