public void WhenConstructed_InitialisValues()
        {
            //Prepare

            //Act
            RevolvingContentControl target = new RevolvingContentControl();

            //Verify
            Assert.AreEqual(1, target.Interval);
            Assert.IsFalse(target.Pause);
            Assert.IsNull(target.ItemsSource);
            Assert.IsNull(target.Items);
        }
Example #2
0
        static void CanExecuteRewindCommand(object sender, CanExecuteRoutedEventArgs e)
        {
            RevolvingContentControl invoker = sender as RevolvingContentControl;

            if (invoker == null || invoker.Items == null || invoker.Items.Count == 0)
            {
                e.CanExecute = false;
            }
            else
            {
                e.CanExecute = true;
            }
        }
        public void WhenItemsSourceIsNull_ContentIsNull()
        {
            //Prepare
            RevolvingContentControl target = new RevolvingContentControl();
            object firstItem = new object();
            object secondItem = new object();
            List<object> items = new List<object> { firstItem, secondItem };
            target.ItemsSource = items;

            //Act
            target.ItemsSource = null;

            //Verify
            Assert.IsNull(target.Content);
        }
        public void WhenIntervalChanged_ValueUpdated()
        {
            //Prepare
            RevolvingContentControl target = new RevolvingContentControl();
            bool delegateCalled = false;
            DependencyPropertyDescriptor.FromProperty(RevolvingContentControl.IntervalProperty,
                typeof(RevolvingContentControl)).AddValueChanged(target, delegate { delegateCalled = true; });

            //Act
            target.Interval = 2;

            //Verify
            Assert.IsTrue(delegateCalled);
            Assert.AreEqual(2, target.Interval);
        }
        public void WhenItemsSourceChanged_ValueUpdated()
        {
            //Prepare
            RevolvingContentControl target = new RevolvingContentControl();
            bool delegateCalled = false;
            List<object> items = new List<object>();
            DependencyPropertyDescriptor.FromProperty(RevolvingContentControl.ItemsSourceProperty,
                typeof(RevolvingContentControl)).AddValueChanged(target, delegate { delegateCalled = true; });

            //Act
            target.ItemsSource = items;

            //Verify
            Assert.IsTrue(delegateCalled);
            Assert.AreEqual(items, target.ItemsSource);
        }
Example #6
0
        static void IntervalCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            RevolvingContentControl control = d as RevolvingContentControl;

            if (control.timer != null)
            {
                control.timer.Stop();
                control.timer.Interval = new TimeSpan(0, 0, control.Interval);
                control.timer.Start();
            }
            else
            {
                control.timer          = new DispatcherTimer(DispatcherPriority.Background);
                control.timer.Interval = new TimeSpan(0, 0, control.Interval);
                control.timer.Tick    += new EventHandler(control.RevolveContent);
            }
        }
Example #7
0
        static void OnRewindCommand(object sender, ExecutedRoutedEventArgs e)
        {
            RevolvingContentControl invoker = sender as RevolvingContentControl;

            if (invoker == null || invoker.Items == null || invoker.Items.Count == 0)
            {
                return;
            }

            invoker.timer.Stop();

            int currentIndex = invoker.Items.IndexOf(invoker.Content);

            if (currentIndex - 1 < 0)
            {
                invoker.Content = invoker.Items.Last();
            }
            else
            {
                invoker.Content = invoker.Items[currentIndex - 1];
            }

            invoker.timer.Start();
        }
        public void WhenItemsSourceSet_ContentUpdated()
        {
            //Prepare
            RevolvingContentControl target = new RevolvingContentControl();
            object firstItem = new object();
            object secondItem = new object();
            List<object> items = new List<object> { firstItem, secondItem };

            //Act
            target.ItemsSource = items;

            //Verify
            Assert.AreEqual(firstItem, target.Content);
        }
        public void WhenNegativeIntervalValue_ValueNegated()
        {
            //Prepare
            RevolvingContentControl target = new RevolvingContentControl();

            //Act
            target.Interval = -2;

            //Verify
            Assert.AreEqual(2, target.Interval);
        }