コード例 #1
0
        public void AlphaRouteConstraintTest(string parameterValue, bool expected)
        {
            // Arrange
            var constraint = new AlphaRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void DecimalRouteConstraint_ApplyConstraint(object parameterValue, bool expected)
        {
            // Arrange
            var constraint = new DecimalRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public void MaxRouteConstraint_ApplyConstraint(long max, int parameterValue, bool expected)
        {
            // Arrange
            var constraint = new MaxRouteConstraint(max);

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #4
0
        public void MaxLengthRouteConstraint_ApplyConstraint(int min, string parameterValue, bool expected)
        {
            // Arrange
            var constraint = new MaxLengthRouteConstraint(min);

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #5
0
        public void LengthRouteConstraint_Range_Tests(int min, int max, string parameterValue, bool expected)
        {
            // Arrange
            var constraint = new LengthRouteConstraint(min, max);

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #6
0
        public void LengthRouteConstraint_ExactLength_Tests(int length, string parameterValue, bool expected)
        {
            // Arrange
            var constraint = new LengthRouteConstraint(length);

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #7
0
        public void DateTimeRouteConstraint_IgnoresOtherTypes_ReturnsFalse()
        {
            // Arrange
            var constraint = new DateTimeRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, false);

            // Assert
            Assert.False(actual);
        }
コード例 #8
0
        public void DateTimeRouteConstraint_AcceptsDateTimeObjects_ReturnsTrue()
        {
            // Arrange
            var constraint = new DateTimeRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, DateTime.Now);

            // Assert
            Assert.True(actual);
        }
コード例 #9
0
        public void DateTimeRouteConstraint_ParsesStrings(string parameterValue, bool expected)
        {
            // Arrange
            var constraint = new DateTimeRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #10
0
        public void CompositeRouteConstraint_Match_CallsMatchOnInnerConstraints(
            bool inner1Result,
            bool inner2Result,
            bool expected)
        {
            // Arrange
            var inner1 = MockConstraintWithResult(inner1Result);
            var inner2 = MockConstraintWithResult(inner2Result);

            // Act
            var constraint = new CompositeRouteConstraint(new[] { inner1.Object, inner2.Object });
            var actual     = ConstraintsTestHelper.TestConstraint(constraint, null);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #11
0
        public void GuidRouteConstraint_ApplyConstraint(object parameterValue, bool parseBeforeTest, bool expected)
        {
            // Arrange
            if (parseBeforeTest)
            {
                parameterValue = Guid.Parse(parameterValue.ToString());
            }

            var constraint = new GuidRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }