public void ShouldThrowWhenNonVoidMethodDoesNotExitReadLockOnException()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <MyService>();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            Assert.Catch <Exception>(() =>
                                     service.AssertSynchronizes(s => s.CallWithResultNotExitedOnException("alabama"), Blocking.ReadOn(service.Lock), wrappedObjectMock));
        }
        public void ShouldNotThrowWhenNonVoidMethodIsReadSynchronizedCorrectly()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <MyService>();
            var aLock             = new ReaderWriterLockSlim();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, aLock);

            //WHEN - THEN
            service.AssertSynchronizes(s => s.CallWithResult("alabama"), Blocking.ReadOn(aLock), wrappedObjectMock);
        }
        public void ShouldThrowWhenVoidMethodDoesNotEnterReadLockAtAll()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <MyService>();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            Assert.Catch <Exception>(() =>
                                     service.AssertSynchronizes(wrappedObjectMock, s => s.VoidCallNotEntered(1), Blocking.ReadOn(service.Lock)));
        }