コード例 #1
0
        public void ShouldAssignIdIfPresentInParameters()
        {
           var request = CreateRequestContext("NamingConvention", "method_requires_id", "POST", id: "34");
            var adapter = new NamingConventionAdapter();

            _methodInvoker.InvokeAdapterMethod(request, adapter);

            Assert.IsTrue(adapter.WasMethodCalled(a => a.method_requires_id(34, new {})));
        }
コード例 #2
0
        public void ShouldCallCorrectMethodOverloadBasedOnHttpVerb()
        {
            var request = CreateRequestContext("NamingConvention", "name_with_underscores", "POST");
            var adapter = new NamingConventionAdapter();

            _methodInvoker.InvokeAdapterMethod(request, adapter);

            Assert.IsTrue(adapter.WasMethodCalled(a => a.name_with_underscores(new { })));
        }
コード例 #3
0
        public void ShouldInferMethodNameFromPath()
        {
            var request = CreateRequestContext("NamingConvention", "name_with_underscores");
            var adapter = new NamingConventionAdapter();

            _methodInvoker.InvokeAdapterMethod(request, adapter);

            Assert.IsTrue(adapter.WasMethodCalled(a => a.name_with_underscores()));
        }
コード例 #4
0
        public void ShouldCallMethodWithCorrectParameters()
        {
            var request = CreateRequestContext("NamingConvention", "name_with_underscores", query: "id=123&provider=fake&project=myProj");
            var adapter = new NamingConventionAdapter();

            _methodInvoker.InvokeAdapterMethod(request, adapter);

            Assert.IsTrue(adapter.WasMethodCalled(
                a => a.name_with_underscores(123, "fake", "myProj")));
        }
コード例 #5
0
        private void ConfirmMethodIsCalledForHttpVerbByNamingConvention(String httpVerb, String methodName, Expression<Action<NamingConventionAdapter>> expectedMethod)
        {
            var request = CreateRequestContext("NamingConvention", methodName, httpVerb);
            var adapter = new NamingConventionAdapter();

            _methodInvoker.InvokeAdapterMethod(request, adapter);

            Assert.IsTrue(adapter.WasMethodCalled(expectedMethod), "Expected method {0}{1} to be called", httpVerb, methodName);
        }