Exemplo n.º 1
0
        public void Does_add_CustomAttributes_to_when_added_in_AppHost_constructor()
        {
            using (var appHost = new RuntimeAttributeAppHost().Init())
            {
                string contentType;
                var    restPath = RestHandler.FindMatchingRestPath("GET", "/custom-register", out contentType);

                Assert.That(restPath, Is.Not.Null);
                Assert.That(restPath.RequestType, Is.EqualTo(typeof(Register)));

                //Allows JSON
                appHost.ServiceController.AssertServiceRestrictions(typeof(Register), RequestAttributes.Json);

                Assert.Throws <UnauthorizedAccessException>(() =>
                                                            appHost.ServiceController.AssertServiceRestrictions(typeof(Register), RequestAttributes.Xml));
            }
        }
        public void Does_add_CustomAttributes_to_when_added_in_AppHost_constructor()
        {
            using (var appHost = new RuntimeAttributeAppHost().Init())
            {
                string contentType;
                var restPath = RestHandler.FindMatchingRestPath("GET", "/custom-register", out contentType);

                Assert.That(restPath, Is.Not.Null);
                Assert.That(restPath.RequestType, Is.EqualTo(typeof(Register)));

                //Allows JSON
                appHost.ServiceController.AssertServiceRestrictions(typeof(Register), RequestAttributes.Json);

                Assert.Throws<UnauthorizedAccessException>(() =>
                    appHost.ServiceController.AssertServiceRestrictions(typeof(Register), RequestAttributes.Xml));
            }
        }