コード例 #1
0
        public void Negative_NullablePostconditionMethod_ThrowsIfPosiitive()
        {
            var demo = new NegativeConsumer();

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PostconditionNullableMethod(1));
        }
コード例 #2
0
        public void Negative_NullablePreconditionMethod_ThrowsIf0()
        {
            var demo = new NegativeConsumer();

            Assert.Throws <PreconditionException>(() =>
                                                  demo.PreconditionNullableMethod(0));
        }
コード例 #3
0
        public void Negative_NullablePostconditionMethod_DoesNotThrowIfNull()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionNullableMethod(null));
        }
コード例 #4
0
        public void Negative_PreAndPostconditionMethod_ThrowsIfArgPositive()
        {
            var demo = new NegativeConsumer();

            Assert.Throws <PreconditionException>(() =>
                                                  demo.PreAndPostconditionMethod(100));
        }
コード例 #5
0
        public void Negative_MultiplePreconditionsMethod_DoesNotThrowIfArgsNegative()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.MultiplePreconditionsMethod(-1, -3.14));
        }
コード例 #6
0
        public void Negative_PreAndPostconditionMethod_DoesNotThrowIfArgAndResultNegative()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PreAndPostconditionMethod(-100));
        }
コード例 #7
0
        public void Negative_PostconditionMethod_ThrowsIf0()
        {
            var demo = new NegativeConsumer();

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PostconditionMethod(0));
        }
コード例 #8
0
        public void Negative_PostconditionMethod_DoesNotThrowIfNegative()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.PostconditionMethod(-1));
        }
コード例 #9
0
        public void Negative_NormalMethod_DoesNotThrow()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() =>
                                demo.NormalMethod());
        }
コード例 #10
0
        public void Negative_ContractReadWriteProperty_SetThrowsIfPositive()
        {
            var demo = new NegativeConsumer();

            Assert.Throws <PreconditionException>(() => {
                demo.ContractReadWriteProperty = 1;
            });
        }
コード例 #11
0
        public void Negative_ContractReadWriteProperty_SetDoesNotThrowIfNegative()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() => {
                demo.ContractReadWriteProperty = -1;
            });
        }
コード例 #12
0
        public void Negative_NormalProperty_SetDoesNotThrow()
        {
            var demo = new NegativeConsumer();

            Assert.DoesNotThrow(() => {
                demo.NormalReadWriteProperty = 0;
            });
        }
コード例 #13
0
        public void Negative_PreAndPostconditionMethod_ThrowsIfResult0()
        {
            var           demo          = new NegativeConsumer();
            Func <string> textGenerator = () => null;

            Assert.Throws <PostconditionException>(() =>
                                                   demo.PreAndPostconditionMethod(-1));
        }
コード例 #14
0
        public void Negative_ContractReadWriteProperty_GetThrowsIfPositive()
        {
            var demo = new NegativeConsumer();

            demo._readWritePropertyWithContract = 1;

            Assert.Throws <PostconditionException>(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
コード例 #15
0
        public void Negative_ContractReadWriteProperty_GetDoesNotThrowIfNegative()
        {
            var demo = new NegativeConsumer();

            demo._readWritePropertyWithContract = -1;

            Assert.DoesNotThrow(() => {
                var x = demo.ContractReadWriteProperty;
            });
        }
コード例 #16
0
        public void Negative_MultiplePreconditionsMethod_ThrowsIfAnyArgPositive()
        {
            var demo = new NegativeConsumer();

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

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