Example #1
0
        public void NonPositive_NullablePostconditionMethod_DoesNotThrowIfNull()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionNullableMethod(null));
        }
Example #2
0
        public void NonPositive_NullablePostconditionMethod_ThrowsIfPositive()
        {
            var demo = new NonPositiveConsumer();

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PostconditionNullableMethod(1));
        }
Example #3
0
        public void NonPositive_MultiplePreconditionsMethod_DoesNotThrowIfArgsNonPositive()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.MultiplePreconditionsMethod(-1, 0));
        }
Example #4
0
        public void NonPositive_NullablePreconditionMethod_DoesNotThrowIfNegative()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PreconditionNullableMethod(-1));
        }
Example #5
0
        public void NonPositive_PreAndPostconditionMethod_ThrowsIfArgPositive()
        {
            var demo = new NonPositiveConsumer();

            Assert.Throws <PreconditionException>(() =>
                                                  demo.PreAndPostconditionMethod(1));
        }
Example #6
0
        public void NonPositive_PreAndPostconditionMethod_DoesNotThrowIfArgAndResultNegative()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PreAndPostconditionMethod(-1));
        }
Example #7
0
        public void NonPositive_PostconditionMethod_DoesNotThrowIf0()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionMethod(0));
        }
Example #8
0
        public void NonPositive_NormalMethod_DoesNotThrow()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() =>
                                demo.NormalMethod());
        }
Example #9
0
        public void NonPositive_ContractReadWriteProperty_SetThrowsIfPositive()
        {
            var demo = new NonPositiveConsumer();

            Assert.Throws <PreconditionException>(() => {
                demo.ContractReadWriteProperty = 1;
            });
        }
Example #10
0
        public void NonPositive_ContractReadWriteProperty_SetDoesNotThrowIf0()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() => {
                demo.ContractReadWriteProperty = 0;
            });
        }
Example #11
0
        public void NonPositive_NormalProperty_SetDoesNotThrow()
        {
            var demo = new NonPositiveConsumer();

            Assert.DoesNotThrow(() => {
                demo.NormalReadWriteProperty = 0;
            });
        }
Example #12
0
        public void NonPositive_PreAndPostconditionMethod_ThrowsIfResultPositive()
        {
            var           demo          = new NonPositiveConsumer();
            Func <string> textGenerator = () => null;

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PreAndPostconditionMethod(0));
        }
Example #13
0
        public void NonPositive_ContractReadWriteProperty_GetThrowsIfPositive()
        {
            var demo = new NonPositiveConsumer();

            demo._readWritePropertyWithContract = 1;

            Assert.Throws <PostconditionException>(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
Example #14
0
        public void NonPositive_ContractReadWriteProperty_GetDoesNotThrowIf0()
        {
            var demo = new NonPositiveConsumer();

            demo._readWritePropertyWithContract = 0;

            Assert.DoesNotThrow(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
Example #15
0
        public void NonPositive_MultiplePreconditionsMethod_ThrowsIfAnyArgPositive()
        {
            var demo = new NonPositiveConsumer();

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

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