示例#1
0
        public void Constructor1SetsProperties()
        {
            // All combination of formatters presented to ctor should still set XmlFormatter
            foreach (IEnumerable <MediaTypeFormatter> formatterCollection in HttpUnitTestDataSets.AllFormatterCollections)
            {
                MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(formatterCollection);
                if (collection.OfType <XmlMediaTypeFormatter>().Any())
                {
                    Assert.NotNull(collection.XmlFormatter);
                }
                else
                {
                    Assert.Null(collection.XmlFormatter);
                }

                if (collection.OfType <JsonMediaTypeFormatter>().Any())
                {
                    Assert.NotNull(collection.JsonFormatter);
                }
                else
                {
                    Assert.Null(collection.JsonFormatter);
                }
            }
        }
        public void Constructor1_SetsProperties(IEnumerable <MediaTypeFormatter> formatterCollection)
        {
            MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(formatterCollection);

            if (collection.OfType <XmlMediaTypeFormatter>().Any())
            {
                Assert.NotNull(collection.XmlFormatter);
            }
            else
            {
                Assert.Null(collection.XmlFormatter);
            }

            if (collection.OfType <JsonMediaTypeFormatter>().Any())
            {
                Assert.NotNull(collection.JsonFormatter);
            }
            else
            {
                Assert.Null(collection.JsonFormatter);
            }
        }