Ejemplo n.º 1
0
        public void Is_Auto_Registered()
        {
            HttpConfiguration          configuration = new HttpConfiguration();
            DefaultODataActionResolver resolver      = configuration.GetODataActionResolver() as DefaultODataActionResolver;

            Assert.NotNull(resolver);
        }
 public void Can_find_action(string actionName, string url)
 {
     IODataActionResolver resolver = new DefaultODataActionResolver();
     ODataDeserializerContext context = new ODataDeserializerContext { Request = GetPostRequest(url), Model = GetModel() };
     IEdmFunctionImport action = resolver.Resolve(context);
     Assert.NotNull(action);
     Assert.Equal(actionName, action.Name);
 }
 public void Throws_InvalidOperation_when_multiple_overloads_found()
 {
     IODataActionResolver resolver = new DefaultODataActionResolver();
     ODataDeserializerContext context = new ODataDeserializerContext { Request = GetPostRequest("http://server/service/Vehicles/Container.Car(8)/Park"), Model = GetModel() };
     InvalidOperationException ioe = Assert.Throws<InvalidOperationException>(() =>
     {
         IEdmFunctionImport action = resolver.Resolve(context);
     }, "Action resolution failed. Multiple actions matching the action identifier 'Park' were found. The matching actions are: org.odata.Container.Park, org.odata.Container.Park.");
 }
 public void Throws_InvalidOperation_when_action_not_found()
 {
     IODataActionResolver resolver = new DefaultODataActionResolver();
     ODataDeserializerContext context = new ODataDeserializerContext { Request = GetPostRequest("http://server/service/MissingOperation"), Model = GetModel() };
     Assert.Throws<InvalidOperationException>(() =>
     {
         IEdmFunctionImport action = resolver.Resolve(context);
     },  "Action 'MissingOperation' was not found for RequestUri 'http://server/service/MissingOperation'.");
 }
Ejemplo n.º 5
0
 public void Throws_InvalidOperation_when_multiple_overloads_found()
 {
     IODataActionResolver     resolver = new DefaultODataActionResolver();
     ODataDeserializerContext context  = new ODataDeserializerContext {
         Request = GetPostRequest("http://server/service/Vehicles/Container.Car(8)/Park"), Model = GetModel()
     };
     InvalidOperationException ioe = Assert.Throws <InvalidOperationException>(() =>
     {
         IEdmFunctionImport action = resolver.Resolve(context);
     }, "Action resolution failed. Multiple actions matching the action identifier 'Park' were found. The matching actions are: org.odata.Container.Park, org.odata.Container.Park.");
 }
Ejemplo n.º 6
0
        public void Can_find_action(string actionName, string url)
        {
            IODataActionResolver     resolver = new DefaultODataActionResolver();
            ODataDeserializerContext context  = new ODataDeserializerContext {
                Request = GetPostRequest(url), Model = GetModel()
            };
            IEdmFunctionImport action = resolver.Resolve(context);

            Assert.NotNull(action);
            Assert.Equal(actionName, action.Name);
        }
Ejemplo n.º 7
0
        public void Throws_InvalidOperation_when_action_not_found()
        {
            IODataActionResolver     resolver = new DefaultODataActionResolver();
            ODataDeserializerContext context  = new ODataDeserializerContext {
                Request = GetPostRequest("http://server/service/MissingOperation"), Model = GetModel()
            };

            Assert.Throws <InvalidOperationException>(() =>
            {
                IEdmFunctionImport action = resolver.Resolve(context);
            }, "Action 'MissingOperation' was not found for RequestUri 'http://server/service/MissingOperation'.");
        }
        public void Can_find_action_overload_using_bindingparameter_type()
        {
            string url = "http://server/service/Vehicles(8)/Container.Car/Wash";
            IODataActionResolver resolver = new DefaultODataActionResolver();
            ODataDeserializerContext context = new ODataDeserializerContext { Request = GetPostRequest(url), Model = GetModel() };

            // TODO: Requires improvements in Uri Parser so it can establish type of path segment prior to ActionName
            // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
            // the test once the bug is fixed).
            // The following assert shows the behavior with the bug and should be removed once the bug is fixed.

            Assert.Throws<InvalidOperationException>(() => resolver.Resolve(context));

            // TODO: DateTimeOffsets are not handled well in the uri parser
            // The following calls show the behavior without the bug, and should be enabled once the bug is fixed.
            //IEdmFunctionImport action = resolver.Resolve(context);
            //Assert.NotNull(action);
            //Assert.Equal("Car", action.Parameters.First().Name);
        }
Ejemplo n.º 9
0
        public void Can_find_action_overload_using_bindingparameter_type()
        {
            string url = "http://server/service/Vehicles(8)/Container.Car/Wash";
            IODataActionResolver     resolver = new DefaultODataActionResolver();
            ODataDeserializerContext context  = new ODataDeserializerContext {
                Request = GetPostRequest(url), Model = GetModel()
            };

            // TODO: Requires improvements in Uri Parser so it can establish type of path segment prior to ActionName
            // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
            // the test once the bug is fixed).
            // The following assert shows the behavior with the bug and should be removed once the bug is fixed.

            Assert.Throws <InvalidOperationException>(() => resolver.Resolve(context));

            // TODO: DateTimeOffsets are not handled well in the uri parser
            // The following calls show the behavior without the bug, and should be enabled once the bug is fixed.
            //IEdmFunctionImport action = resolver.Resolve(context);
            //Assert.NotNull(action);
            //Assert.Equal("Car", action.Parameters.First().Name);
        }