Beispiel #1
0
        public void RequiresNonNullString_Returns_String_When_NotEmpty()
        {
            var    ctr = new ClassWithContract();
            string ret = ctr.RequiresNonNullString("TestString");

            Assert.Equal("TestString", ret);
        }
Beispiel #2
0
        public void RequiresNonNullString_When_Passed_Null_Fires_ContractFailed()
        {
            bool contractFailed = false;

            Contract.ContractFailed += (o, e) =>
            {
                e.SetHandled();
                contractFailed = true;
            };

            var    ctr = new ClassWithContract();
            string ret = ctr.RequiresNonNullString(null);

            Assert.True(contractFailed);
        }