コード例 #1
0
        public void SaveInvokeTest()
        {
            BaseTest();
            string routeKey  = RouteKey.CreateRequestKey("/testcontroller/movies");
            var    routeSave = _requestActionRouteDictionary[routeKey];

            Assert.NotNull(routeSave);

            var parameter = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            var response  = routeSave.Invoke(new ChromelyRequest("/testcontroller/movies", null, parameter));

            Assert.NotNull(response);
            Assert.True(response.Data is string);
            Assert.Equal(parameter, (string)response.Data);
        }
コード例 #2
0
        public void Get1InvokeTest()
        {
            BaseTest();

            string routeKey  = RouteKey.CreateRequestKey("/testcontroller/movies/1");
            var    routeGet1 = _requestActionRouteDictionary[routeKey];

            Assert.NotNull(routeGet1);

            var response = routeGet1.Invoke(new ChromelyRequest("/testcontroller/movies/1", null, null));

            Assert.NotNull(response);
            Assert.True(response.Data is int);
            Assert.Equal(1000, (int)response.Data);
        }
コード例 #3
0
        public void Get2InvokeTest()
        {
            BaseTest();

            string routeKey  = RouteKey.CreateRequestKey("/testcontroller/movies/2");
            var    routeGet2 = _requestActionRouteDictionary[routeKey];

            Assert.NotNull(routeGet2);

            IChromelyResponse response = routeGet2.Invoke(new ChromelyRequest("/testcontroller/movies/2", null, null));

            Assert.NotNull(response);
            Assert.True(response.Data is string);
            Assert.Equal("Test Get 2", (string)response.Data);
        }
コード例 #4
0
        public virtual RequestActionRoute GetActionRoute(string routeUrl)
        {
            var key = RouteKey.CreateRequestKey(routeUrl);

            if (string.IsNullOrWhiteSpace(key))
            {
                return(null);
            }

            EnsureContainersAreInitialized();
            if (ActionRouteDictionary.ContainsKey(key))
            {
                return(ActionRouteDictionary[key]);
            }

            return(null);
        }