コード例 #1
0
        public void WithArgument_NullArrayForTwoArguments_ArgumentNullExceptionThrown()
        {
            // Arrange
            var context = new ContractTestContext <int, int>("", (a, b) => { });

            // Action & Assert
            Assert.ThrowsException <ArgumentNullException>(() => context.WithArguments(null));
        }
コード例 #2
0
        public void WithArgument_EmptyArray_ArgumentExceptionThrown()
        {
            // Arrange
            var context = new ContractTestContext <int>("", a => { });

            // Action & Assert
            Assert.ThrowsException <ArgumentException>(() => context.WithArguments());
        }
コード例 #3
0
        public void WithArgument_NullAsSingleArgument_TestCaseCreated()
        {
            // Arrange
            var context = new ContractTestContext <int>("", a => { });

            // Action
            context.WithArguments(null);

            // Assert
            var cases = ContractTest.Method.Current;

            Assert.AreEqual(1, cases.Count);
        }
コード例 #4
0
        public void WithArgument_NullAsSingleArgumentForFormattedContract_TestCaseContractFormattedNull()
        {
            // Arrange
            var context = new ContractTestContext <string>("{0} is my money", a => { });

            // Action
            context.WithArguments(null);

            // Assert
            var cases    = ContractTest.Method.Current;
            var contract = cases[0].DisplayName;

            Assert.AreEqual("Null is my money", contract);
        }
コード例 #5
0
        public void WithArgument_NullAsSingleArgument_TestCaseContractAppendNull()
        {
            // Arrange
            var context = new ContractTestContext <string>("My money is ", a => { });

            // Action
            context.WithArguments(null);

            // Assert
            var cases    = ContractTest.Method.Current;
            var contract = cases[0].DisplayName;

            Assert.AreEqual("My money is (Null)", contract);
        }
コード例 #6
0
        public void WithArgument_GetUnitTestResult_TestCaseExecuted()
        {
            // Arrange
            var executed = false;
            var context  = new ContractTestContext <int>("", a => executed = true);

            // Action
            context.WithArguments(0);
            var result = ContractTest.Method.Current.Single().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(executed);
        }