示例#1
0
        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);
        }
示例#2
0
        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>();
        }
示例#3
0
        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>();
        }