public void CollectionToOtherElementConcurrentStack()
        {
            var converter   = new TestObjectConverter();
            var source      = new WrapperCollection <int>(new[] { 0, 1 });
            var destination = (ConcurrentStack <string>)converter.Convert(source, typeof(ConcurrentStack <string>));

            Assert.Equal(2, destination.Count);
            Assert.Contains("0", destination);
            Assert.Contains("1", destination);
            Assert.True(converter.UsedIn(typeof(EnumerableConverterFactory), typeof(ToStringConverterFactory)));
        }
        public void CollectionToSameElementConcurrentStack()
        {
            var converter   = new TestObjectConverter();
            var source      = new WrapperCollection <int>(new[] { 0, 1 });
            var destination = (ConcurrentStack <int>)converter.Convert(source, typeof(ConcurrentStack <int>));

            Assert.Equal(2, destination.Count);
            Assert.Contains(0, destination);
            Assert.Contains(1, destination);
            Assert.True(converter.UsedOnly <EnumerableConverterFactory>());
        }
Ejemplo n.º 3
0
        public void CollectionToOtherElementReadOnlyCollection()
        {
            var converter   = new TestObjectConverter();
            var source      = new WrapperCollection <int>(new[] { 0, 1 });
            var destination = (ReadOnlyCollection <string>)converter.Convert(source, typeof(ReadOnlyCollection <string>));

            Assert.Equal(2, destination.Count);
            Assert.Equal("0", destination[0]);
            Assert.Equal("1", destination[1]);
            Assert.True(converter.UsedIn(typeof(EnumerableConverterFactory), typeof(ToStringConverterFactory)));
        }
Ejemplo n.º 4
0
        public void CollectionToSameElementReadOnlyCollection()
        {
            var converter   = new TestObjectConverter();
            var source      = new WrapperCollection <int>(new[] { 0, 1 });
            var destination = (ReadOnlyCollection <int>)converter.Convert(source, typeof(ReadOnlyCollection <int>));

            Assert.Equal(2, destination.Count);
            Assert.Equal(0, destination[0]);
            Assert.Equal(1, destination[1]);
            Assert.True(converter.UsedOnly <EnumerableConverterFactory>());
        }
Ejemplo n.º 5
0
        public void test_WrapperCollection()
        {
            NotifyCollectionChangedAction lastAction = NotifyCollectionChangedAction.Reset;
            object        lastAdd       = null;
            object        lastRemove    = null;
            int           changeCounter = 0;
            EventReceiver onAdd         = new EventReceiver((x, y) => lastAdd = ((ObjectEventArgs)y).Arg),
                          onRemove      = new EventReceiver((x, y) => lastRemove = ((ObjectEventArgs)y).Arg),
                          onChange      = new EventReceiver((x, y) => ++ changeCounter);

            var targetColl = new WeakObservableCollection <string>();
            var wcoll      = new WrapperCollection <string>(targetColl);

            wcoll.Added.AddReceiver(onAdd);
            wcoll.Removed.AddReceiver(onRemove);
            wcoll.Changed.AddReceiver(onChange);
            wcoll.CollectionChanged += (x, y) => { lastAction = y.Action; };

            string t1 = "aaa", t2 = "bbb";

            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(0, changeCounter);

            targetColl.Add(t1);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(1, changeCounter);
            Assert.AreEqual(t1, lastAdd);
            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastAction);

            targetColl.Add(t2);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(2, changeCounter);
            Assert.AreEqual(t2, lastAdd);
            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastAction);

            targetColl.Remove(t1);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(3, changeCounter);
            Assert.AreEqual(t1, lastRemove);
            Assert.AreEqual(NotifyCollectionChangedAction.Remove, lastAction);

            Assert.AreEqual(targetColl.Count, wcoll.Count);
        }
 public CaptureDeviceManager()
 {
     wrappers = new WrapperCollection <CaptureDevice>(createWrapper, destroyWrapper);
 }
Ejemplo n.º 7
0
 public AudioCodecManager()
 {
     codecs = new WrapperCollection <AudioCodec>(createWrapper, destroyWrapper);
 }
Ejemplo n.º 8
0
        public void test_WrapperCollection()
        {
            NotifyCollectionChangedAction lastAction = NotifyCollectionChangedAction.Reset;
            object lastAdd = null;
            object lastRemove = null;
            int changeCounter = 0;
            EventReceiver onAdd = new EventReceiver((x, y) => lastAdd = ((ObjectEventArgs)y).Arg),
                onRemove = new EventReceiver((x, y) => lastRemove = ((ObjectEventArgs)y).Arg),
                onChange = new EventReceiver((x, y) => ++changeCounter);

            var targetColl = new WeakObservableCollection<string>();
            var wcoll = new WrapperCollection<string>(targetColl);

            wcoll.Added.AddReceiver(onAdd);
            wcoll.Removed.AddReceiver(onRemove);
            wcoll.Changed.AddReceiver(onChange);
            wcoll.CollectionChanged += (x, y) => { lastAction = y.Action; };

            string t1 = "aaa", t2 = "bbb";

            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(0, changeCounter);

            targetColl.Add(t1);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(1, changeCounter);
            Assert.AreEqual(t1, lastAdd);
            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastAction);

            targetColl.Add(t2);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(2, changeCounter);
            Assert.AreEqual(t2, lastAdd);
            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastAction);

            targetColl.Remove(t1);
            CompareWrap(targetColl, wcoll, t1, t2);
            Assert.AreEqual(3, changeCounter);
            Assert.AreEqual(t1, lastRemove);
            Assert.AreEqual(NotifyCollectionChangedAction.Remove, lastAction);

            Assert.AreEqual(targetColl.Count, wcoll.Count);
        }