Esempio n. 1
0
        public void ShouldNotThrowWhenNonVoidMethodIsWriteSynchronizedCorrectly()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var service           = new WriteSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            service.Should().SynchronizeAccessTo(s => s.CallWithResult("alabama"), Blocking.WriteOn(service.Lock), wrappedObjectMock);
        }
Esempio n. 2
0
        public void ShouldThrowWhenNonVoidMethodDoesNotExitWriteLockOnException()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var service           = new WriteSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            new Action(() =>
                       service.Should().SynchronizeAccessTo(s => s.CallWithResultNotExitedOnException("alabama"), Blocking.WriteOn(service.Lock), wrappedObjectMock))
            .Should().ThrowExactly <XunitException>();
        }
Esempio n. 3
0
        public void ShouldThrowWhenVoidMethodDoesNotEnterWriteLockAtAll()
        {
            //GIVEN
            var wrappedObjectMock = Substitute.For <IMyService>();
            var service           = new WriteSynchronizedMyService(wrappedObjectMock, new ReaderWriterLockSlim());

            //WHEN - THEN
            new Action(() =>
                       service.Should().SynchronizeAccessTo(s => s.VoidCallNotEntered(1), Blocking.WriteOn(service.Lock), wrappedObjectMock))
            .Should().ThrowExactly <ReceivedCallsException>();
        }