示例#1
0
 public void ExitingSetsIsBusyToFalseAgain()
 {
     var busyState = new BusyState();
     busyState.Enter();
     busyState.Exit();
     Assert.IsFalse(busyState.IsBusy);
 }
示例#2
0
 public void CanUseUsingBlock()
 {
     var busyState = new BusyState();
     using (busyState.Enter())
     {
         Assert.IsTrue(busyState.IsBusy);
     }
     Assert.IsFalse(busyState.IsBusy);
 }
示例#3
0
        public void DoesntGetItsKnickersInATwistWhenExitingTooManyTimes()
        {
            var busyState = new BusyState();
            busyState.Exit();   
            busyState.Exit();
            busyState.Exit();
            Assert.IsFalse(busyState.IsBusy);

            busyState.Enter();
            Assert.IsTrue(busyState.IsBusy);
        }
示例#4
0
 public void MustCallExitSameNumberOfTimesAsEnter()
 {
     var busyState = new BusyState();
     busyState.Enter();
     busyState.Enter();
     busyState.Enter();
     busyState.Exit();
     Assert.IsTrue(busyState.IsBusy);
     busyState.Exit();
     Assert.IsTrue(busyState.IsBusy);
     busyState.Exit();
     Assert.IsFalse(busyState.IsBusy);
 }
示例#5
0
        public void RaisesPropertyChangedOnIsBusyChanged()
        {
            var changes = new Queue<string>();

            var busyState = new BusyState();
            busyState.PropertyChanged += (x, e) => changes.Enqueue(e.PropertyName);
            
            busyState.Enter();
            Assert.AreEqual("IsBusy", changes.Dequeue());
            busyState.Enter();
            Assert.AreEqual(0, changes.Count);

            busyState.Exit();
            Assert.AreEqual(0, changes.Count);
            busyState.Exit();
            Assert.AreEqual("IsBusy", changes.Dequeue());

            Assert.AreEqual(0, changes.Count);
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BackgroundOperationCollection"/> class.
 /// </summary>
 /// <param name="busyState">State of the busy.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public BackgroundOperationCollection(BusyState busyState, IDispatcher dispatcher)
 {
     this.busyState  = busyState;
     this.dispatcher = dispatcher;
     activeOperations.CollectionChanged += (x, y) => OnCollectionChanged(y);
 }
示例#7
0
 public void EnteringSetsIsBusyToTrue()
 {
     var busyState = new BusyState();
     busyState.Enter();
     Assert.IsTrue(busyState.IsBusy);
 }
示例#8
0
 public void WhenInitializedIsNotBusy()
 {
     var busyState = new BusyState();
     Assert.IsFalse(busyState.IsBusy);
 }