public void ShouldNotThrowWhenNonVoidMethodIsMonitorSynchronizedCorrectly() { //GIVEN var wrappedObjectMock = Substitute.For <IMyService>(); var service = new MonitorSynchronizedMyService(wrappedObjectMock, new object()); //WHEN - THEN service.Should().SynchronizeAccessTo(s => s.CallWithResult("alabama"), Blocking.MonitorOn(service.Lock), wrappedObjectMock); }
public void ShouldThrowWhenNonVoidMethodDoesNotExitMonitor() { //GIVEN var wrappedObjectMock = Substitute.For <IMyService>(); var service = new MonitorSynchronizedMyService(wrappedObjectMock, new object()); //WHEN - THEN new Action(() => service.Should().SynchronizeAccessTo(s => s.CallWithResultNotExited("alabama"), Blocking.MonitorOn(service.Lock), wrappedObjectMock)) .Should().ThrowExactly <Exception>(); }
public void ShouldThrowWhenVoidMethodDoesNotExitMonitorOnException() { //GIVEN var wrappedObjectMock = Substitute.For <IMyService>(); var service = new MonitorSynchronizedMyService(wrappedObjectMock, new object()); //WHEN - THEN new Action(() => service.Should().SynchronizeAccessTo(s => s.VoidCallNotExitedOnException(1), Blocking.MonitorOn(service.Lock), wrappedObjectMock)) .Should().ThrowExactly <ReceivedCallsException>(); }