Esempio n. 1
0
        public void ctor_IsNotLatched()
        {
            // Arrange
            var classUnderTest = new FullLatch();

            // Act

            // Assert
            Assert.IsFalse(classUnderTest.IsLatched);
        }
Esempio n. 2
0
        public void RunIfNotLatched_CallBarWhileLatched_BarIsNotCalled()
        {
            // Arrange
            var classUnderTest = new FullLatch();
            var foo            = A.Fake <IFoo>();

            // Act
            classUnderTest.LatchAndRun(() => classUnderTest.RunIfNotLatched(foo.Bar));

            // Assert
            A.CallTo(() => foo.Bar()).MustNotHaveHappened();
        }
Esempio n. 3
0
        public void RunIfNotLatched_GiveBar_BarIsCalled()
        {
            // Arrange
            var classUnderTest = new FullLatch();
            var foo            = A.Fake <IFoo>();

            // Act
            classUnderTest.RunIfNotLatched(foo.Bar);

            // Assert
            A.CallTo(() => foo.Bar()).MustHaveHappened();
        }
Esempio n. 4
0
        public void LatchAndRun_CheckWhileLatching_IsLatchedIsTrue()
        {
            // Arrange
            var classUnderTest = new FullLatch();

            // Act
            bool isLatched = false;

            classUnderTest.LatchAndRun(() => isLatched = classUnderTest.IsLatched);

            // Assert
            Assert.IsTrue(isLatched);
        }
Esempio n. 5
0
        public void LatchAndRun_BarThrows_IsLatchedIsFalseAfterBarAndExceptionWasNotSwallowed()
        {
            // Arrange
            var classUnderTest = new FullLatch();
            var foo            = A.Fake <IFoo>();

            A.CallTo(() => foo.Bar()).Throws(new DivideByZeroException());

            // Act
            Assert.Throws(typeof(DivideByZeroException), () => classUnderTest.LatchAndRun(foo.Bar));

            // Assert
            Assert.IsFalse(classUnderTest.IsLatched);
        }