Exemple #1
0
        public void MatchShouldReturnTheMatchedInformation()
        {
            MethodInfo method = Substitute.For <MethodInfo>();
            IReadOnlyDictionary <string, object> parameters = new Dictionary <string, object>();
            ILookup <string, string>             query      = Substitute.For <ILookup <string, string> >();

            // We need to call the Arg.XXX calls in the same order as the method
            // for NSubstitute to handle them and we need to use the specifier
            // for both string parameters so it doesn't get confused
            string verb = Arg.Is("GET");
            string path = Arg.Is("/route");
            IReadOnlyDictionary <string, object> any = Arg.Any <IReadOnlyDictionary <string, object> >();

            this.mapper.Match(verb, path, query, out any)
            .Returns(args =>
            {
                args[3] = parameters;
                return(method);
            });

            RequestProcessor.MatchResult result =
                this.processor.Match("GET", "/route", query);

            Assert.That(result.Success, Is.True);
            Assert.That(result.Method, Is.SameAs(method));
            Assert.That(result.Parameters, Is.SameAs(parameters));
        }
Exemple #2
0
        public void MatchShouldReturnFalseIfNotMethodMatches()
        {
            IReadOnlyDictionary <string, object> notUsed;

            this.mapper.Match(null, null, null, out notUsed).ReturnsForAnyArgs((MethodInfo)null);

            RequestProcessor.MatchResult result =
                this.processor.Match("", "", Substitute.For <ILookup <string, string> >());

            Assert.That(result.Success, Is.False);
        }