Esempio n. 1
0
 public void InputParameterAreCreatedAllValueAndReferenceTypes()
 {
     TestDataAssert.Execute(
         HttpTestData.RepresentativeValueAndRefTypeTestDataCollection,
         TestDataVariations.All,
         "InputParameters for all types failed.",
         (type, obj) =>
     {
         Type convertType  = obj == null ? type : obj.GetType();
         HttpParameter hpd = new HttpParameter("x", convertType);
         Type expectedType = typeof(HttpResponseMessage <>).MakeGenericType(convertType);
         HttpParameter expectedContentParameter = new HttpParameter("x", expectedType);
         ResponseContentHandler handler         = new ResponseContentHandler(hpd, Enumerable.Empty <MediaTypeFormatter>());
         HttpParameterAssert.Contains(handler.InputParameters, HttpParameter.RequestMessage, "Failed to initialize input parameters for RequestMessage.");
         HttpParameterAssert.Contains(handler.InputParameters, hpd, "Failed to initialize input parameter.");
     });
 }
Esempio n. 2
0
        public void Constructor()
        {
            HttpParameter       hpd = new HttpParameter("x", typeof(int));
            HttpParameter       expectedContentParameter = new HttpParameter("x", typeof(HttpResponseMessage <int>));
            SMediaTypeFormatter formatter = new SMediaTypeFormatter()
            {
                CallBase = true
            };

            MediaTypeFormatter[]   formatters = new MediaTypeFormatter[] { formatter };
            ResponseContentHandler handler    = new ResponseContentHandler(hpd, formatters);

            HttpParameterAssert.Contains(handler.InputParameters, HttpParameter.RequestMessage, "Failed to initialize input parameters for RequestMessage.");
            HttpParameterAssert.Contains(handler.InputParameters, hpd, "Failed to initialize input parameter.");
            HttpParameterAssert.ContainsOnly(handler.OutputParameters, expectedContentParameter, "Failed to initialize content parameter.");
            CollectionAssert.Contains(handler.Formatters, formatter, "Failed to accept mediaTypeFormatter.");
        }