コード例 #1
0
ファイル: PathPart_Tests.cs プロジェクト: awhewell/owin
        [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);
        }
コード例 #2
0
ファイル: PathPart_Tests.cs プロジェクト: awhewell/owin
        [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);
            }
        }
コード例 #3
0
ファイル: PathPart_Tests.cs プロジェクト: awhewell/owin
 public void Create_Throws_If_MethodParameters_Is_Null()
 {
     PathPart.Create("whatever", null);
 }