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); }
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>(); }
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>(); }