예제 #1
0
        public void NonNegative_PreAndPostconditionMethod_DoesNotThrowIfArgAndResultPositive()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PreAndPostconditionMethod(1));
        }
예제 #2
0
        public void NonNegative_MultiplePreconditionsMethod_DoesNotThrowIfArgsNonNegative()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.MultiplePreconditionsMethod(1, 0));
        }
예제 #3
0
        public void NonNegative_PreAndPostconditionMethod_ThrowsIfArgNegative()
        {
            var demo = new NonNegativeConsumer();

            Assert.Throws <PreconditionException>(() =>
                                                  demo.PreAndPostconditionMethod(-1));
        }
예제 #4
0
        public void NonNegative_PostconditionMethod_DoesNotThrowIf0()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionMethod(0));
        }
예제 #5
0
        public void NonNegative_NormalMethod_DoesNotThrow()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.NormalMethod());
        }
예제 #6
0
        public void NonNegative_NullablePostconditionMethod_ThrowsIfNegative()
        {
            var demo = new NonNegativeConsumer();

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PostconditionNullableMethod(-1));
        }
예제 #7
0
        public void NonNegative_NullablePostconditionMethod_DoesNotThrowIfNull()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionNullableMethod(null));
        }
예제 #8
0
        public void NonNegative_NullablePreconditionMethod_DoesNotThrowIfPositive()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PreconditionNullableMethod(1));
        }
예제 #9
0
        public void NonNegative_ContractReadWriteProperty_SetThrowsIfNegative()
        {
            var demo = new NonNegativeConsumer();

            Assert.Throws <PreconditionException>(() => {
                demo.ContractReadWriteProperty = -1;
            });
        }
예제 #10
0
        public void NonNegative_ContractReadWriteProperty_SetDoesNotThrowIf0()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() => {
                demo.ContractReadWriteProperty = 0;
            });
        }
예제 #11
0
        public void NonNegative_NormalProperty_SetDoesNotThrow()
        {
            var demo = new NonNegativeConsumer();

            Assert.DoesNotThrow(() => {
                demo.NormalReadWriteProperty = 0;
            });
        }
예제 #12
0
        public void NonNegative_PreAndPostconditionMethod_ThrowsIfResultNegative()
        {
            var           demo          = new NonNegativeConsumer();
            Func <string> textGenerator = () => null;

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PreAndPostconditionMethod(0));
        }
예제 #13
0
        public void NonNegative_ContractReadWriteProperty_GetThrowsIfNegative()
        {
            var demo = new NonNegativeConsumer();

            demo._readWritePropertyWithContract = -1;

            Assert.Throws <PostconditionException>(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
예제 #14
0
        public void NonNegative_ContractReadWriteProperty_GetDoesNotThrowIf0()
        {
            var demo = new NonNegativeConsumer();

            demo._readWritePropertyWithContract = 0;

            Assert.DoesNotThrow(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
예제 #15
0
        public void NonNegative_MultiplePreconditionsMethod_ThrowsIfAnyArgNegative()
        {
            var demo = new NonNegativeConsumer();

            Assert.Throws <PreconditionException>(() =>
                                                  demo.MultiplePreconditionsMethod(-1, 0));

            Assert.Throws <PreconditionException>(() =>
                                                  demo.MultiplePreconditionsMethod(0, -1));
        }