示例#1
0
        public void ShouldNotThrowWhenNonVoidMethodIsReadSynchronizedCorrectly()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var aLock             = new ReaderWriterLockSlim();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, aLock);

            //WHEN - THEN
            service.Should().SynchronizeAccessTo(s => s.CallWithResult("alabama"), Blocking.ReadOn(aLock), wrappedObjectMock);
        }
示例#2
0
        public void ShouldThrowWhenVoidMethodDoesNotExitReadLockOnException()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            new Action(() =>
                       service.Should().SynchronizeAccessTo(s => s.VoidCallNotExitedOnException(1), Blocking.ReadOn(service.Lock), wrappedObjectMock))
            .Should().ThrowExactly <ReceivedCallsException>();
        }
示例#3
0
        public void ShouldThrowWhenNonVoidMethodDoesNotExitReadLock()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var service           = new ReadSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            new Action(() =>
                       service.Should().SynchronizeAccessTo(s => s.CallWithResultNotExited("alabama"), Blocking.ReadOn(service.Lock), wrappedObjectMock))
            .Should().ThrowExactly <XunitException>();
        }