コード例 #1
0
        public void ShouldIncrementDecrementBusyCounter()
        {
            var busyWatcher = new BusyWatcher();
            busyWatcher.AddWatch();
            Assert.IsTrue(busyWatcher.IsBusy);

            busyWatcher.RemoveWatch();
            Assert.IsFalse(busyWatcher.IsBusy);
        }
コード例 #2
0
        public void BusyWatcher_Should_Throw_When_RemoveWatch_Called_Without_AddWatch()
        {
            var busyWatcher = new BusyWatcher();

            Should.Throw <InvalidOperationException>(() =>
            {
                busyWatcher.RemoveWatch();
            });
        }
コード例 #3
0
        public void ShouldIncrementDecrementBusyCounter()
        {
            var busyWatcher = new BusyWatcher();

            busyWatcher.AddWatch();
            Assert.IsTrue(busyWatcher.IsBusy);

            busyWatcher.RemoveWatch();
            Assert.IsFalse(busyWatcher.IsBusy);
        }
コード例 #4
0
        public void ShoultThrowInvalidOperationException()
        {
            var expectedExceptionThrown = false;

            try
            {
                var busyWatcher = new BusyWatcher();
                busyWatcher.RemoveWatch();
            }
            catch (InvalidOperationException)
            {
                expectedExceptionThrown = true;
            }
            Assert.IsTrue(expectedExceptionThrown);
        }
コード例 #5
0
        public void ShouldNestBusyState()
        {
            var busyWatcher = new BusyWatcher();

            busyWatcher.AddWatch();
            Assert.IsTrue(busyWatcher.IsBusy);

            using (busyWatcher.GetTicket())
            {
                Assert.IsTrue(busyWatcher.IsBusy);
            }

            Assert.IsTrue(busyWatcher.IsBusy);
            busyWatcher.RemoveWatch();
            Assert.IsFalse(busyWatcher.IsBusy);
        }
コード例 #6
0
        public void ShouldNestBusyState()
        {
            var busyWatcher = new BusyWatcher();

            busyWatcher.AddWatch();
            Assert.IsTrue(busyWatcher.IsBusy);

            using (busyWatcher.GetTicket())
            {
                Assert.IsTrue(busyWatcher.IsBusy);
            }

            Assert.IsTrue(busyWatcher.IsBusy);
            busyWatcher.RemoveWatch();
            Assert.IsFalse(busyWatcher.IsBusy);
        }
コード例 #7
0
        public void BusyWatcher_RemoveWatch_Should_Throw_If_Not_Ticket_Present()
        {
            var busyWatcher = new BusyWatcher();

            Should.Throw <InvalidOperationException>(() => busyWatcher.RemoveWatch());
        }
コード例 #8
0
 public void ShoultThrowInvalidOperationException()
 {
     var expectedExceptionThrown = false;
     try
     {
         var busyWatcher = new BusyWatcher();
         busyWatcher.RemoveWatch();
     }
     catch (InvalidOperationException)
     {
         expectedExceptionThrown = true;
     }
     Assert.IsTrue(expectedExceptionThrown);
 }