Ejemplo n.º 1
0
        public void CanReadTypeReturnsTrue()
        {
            SMediaTypeFormatter formatter = new SMediaTypeFormatter()
            {
                CallBase = true
            };

            string[] legalMediaTypeStrings = HttpTestData.LegalMediaTypeStrings.ToArray();
            foreach (string mediaType in legalMediaTypeStrings)
            {
                formatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue(mediaType));
            }

            TestDataAssert.Execute(
                TestData.RepresentativeValueAndRefTypeTestDataCollection,
                (type, obj) =>
            {
                foreach (string mediaType in legalMediaTypeStrings)
                {
                    SStringContent content = new SStringContent("data")
                    {
                        CallBase = true
                    };
                    content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
                    Assert.IsTrue(formatter.CanReadAs(type, content), string.Format("CanReadType should have returned true for '{0}'.", type));
                }
            });
        }
Ejemplo n.º 2
0
        public void CanReadAsThrowsWithNullType()
        {
            SMediaTypeFormatter formatter = new SMediaTypeFormatter()
            {
                CallBase = true
            };
            SStringContent content = new SStringContent("data")
            {
                CallBase = true
            };

            ExceptionAssert.ThrowsArgumentNull("type", () => formatter.CanReadAs(null, content));
        }