Exemplo n.º 1
0
		public void Throws_binding_exception_when_unable_to_bind_request()
		{
			var path = "/request/{id}/path";
			var request = ConfigureRequest(path);
			var response = new Mock<IHttpResponse>().Object;

			var handler = new RestHandler
			{
				RestPath = new RestPath(typeof(RequestType), path)
			};

            try
            {
                handler.ProcessRequestAsync(request, response, string.Empty).Wait();
                Assert.Fail("Should throw SerializationException");
            }
            catch (AggregateException aex)
            {
                Assert.That(aex.InnerExceptions.Count, Is.EqualTo(1));
                Assert.That(aex.InnerException.GetType().Name, Is.EqualTo("SerializationException"));
            }
        }
Exemplo n.º 2
0
		public void Throws_binding_exception_when_unable_to_match_path_values()
		{
			var path = "/request/{will_not_match_property_id}/pathh";
			var request = ConfigureRequest(path);
			var response = new Mock<IHttpResponse>().Object;

			var handler = new RestHandler
			{
				RestPath = new RestPath(typeof(RequestType), path)
			};

		    try
		    {
    		    handler.ProcessRequestAsync(request, response, string.Empty).Wait();
                Assert.Fail("Should throw RequestBindingException");
		    }
		    catch (AggregateException aex)
		    {
                Assert.That(aex.InnerExceptions.Count, Is.EqualTo(1));
                Assert.That(aex.InnerException is RequestBindingException);
		    }
		}