示例#1
0
        public void Validate_RequestedMediaTypes_Throws_ODataException_IfNoMediaTypes_Supported()
        {
            var odataServiceOptions = new ODataServiceOptions(
                ODataVersion.MinVersion,
                ODataVersion.MaxVersion,
                new[] { ODataIsolationLevel.None },
                new[] { "application/json", "text/plain" });

            ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(new[] { "application/xml" }));

            Assert.Equal(ExceptionMessage.MediaTypeNotAcceptable(odataServiceOptions.SupportedMediaTypes, odataServiceOptions.SupportedMetadataLevels, new[] { "application/xml" }), odataException.Message);
            Assert.Equal(HttpStatusCode.NotAcceptable, odataException.StatusCode);
            Assert.Equal("Accept", odataException.Target);
        }