Exemple #1
0
        [DataRow("{id}", null, false)]               // Normalisation coalesces nulls, they do not match anything
        public void MatchesRequestPathPart_Returns_Correct_Response(string ctorPathPart, string matchPathPart, bool expected)
        {
            var methodInfo       = GetType().GetMethod(nameof(MatchesRequestPathPartExampleParameters));
            var methodParameters = MethodParameter_Tests.CreateMethodParameters(methodInfo, null);
            var pathPart         = PathPart.Create(ctorPathPart, methodParameters);

            var actual = pathPart.MatchesRequestPathPart(matchPathPart);

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        [DataRow("{a?}", typeof(PathPartText), "{a?}", "{a?}")]                             // You cannot mark non-default parameters with a question mark.
        public void Create_Fills_Properties(string inputText, Type expectedType, string part, string normalisedPart)
        {
            var methodInfo       = GetType().GetMethod(nameof(ValidExampleParameterNames));
            var methodParameters = MethodParameter_Tests.CreateMethodParameters(methodInfo, null);

            var actual = PathPart.Create(inputText, methodParameters);

            Assert.IsInstanceOfType(actual, expectedType);      // they got the parameters the wrong way round... all other calls are expected then actual
            Assert.AreEqual(part, actual.Part);
            Assert.AreEqual(normalisedPart, actual.NormalisedPart);

            if (expectedType == typeof(PathPartParameter))
            {
                var expectedMethodParameter = methodParameters.First(r => r.NormalisedName == normalisedPart);
                var actualPathPartParameter = (PathPartParameter)actual;
                Assert.AreSame(expectedMethodParameter, actualPathPartParameter.MethodParameter);
            }
        }
Exemple #3
0
 public void Create_Throws_If_MethodParameters_Is_Null()
 {
     PathPart.Create("whatever", null);
 }