예제 #1
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);
 }
예제 #2
0
 public void ExitingSetsIsBusyToFalseAgain()
 {
     var busyState = new BusyState();
     busyState.Enter();
     busyState.Exit();
     Assert.IsFalse(busyState.IsBusy);
 }
예제 #3
0
 public void CanUseUsingBlock()
 {
     var busyState = new BusyState();
     using (busyState.Enter())
     {
         Assert.IsTrue(busyState.IsBusy);
     }
     Assert.IsFalse(busyState.IsBusy);
 }
예제 #4
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);
        }
예제 #5
0
        public void DoesntGetItsKnickersInATwistWhenExitingTooManyTimes()
        {
            var busyState = new BusyState();
            busyState.Exit();   
            busyState.Exit();
            busyState.Exit();
            Assert.IsFalse(busyState.IsBusy);

            busyState.Enter();
            Assert.IsTrue(busyState.IsBusy);
        }
예제 #6
0
 public void EnteringSetsIsBusyToTrue()
 {
     var busyState = new BusyState();
     busyState.Enter();
     Assert.IsTrue(busyState.IsBusy);
 }