Exemplo n.º 1
0
        public void Validate_ODataRequestOptions_Throws_ODataException_If_ODataVersion_BelowMinSupported()
        {
            var odataRequestOptions = new ODataRequestOptions(
                new Uri("https://services.odata.org/OData"),
                ODataIsolationLevel.None,
                ODataMetadataLevel.Minimal,
                ODataVersion.Parse("3.0"), // symantically this makes no sense but the scenario is needed for the test case.
                ODataVersion.OData40);

            var odataServiceOptions = new ODataServiceOptions(
                ODataVersion.MinVersion,
                ODataVersion.MaxVersion,
                new[] { ODataIsolationLevel.None },
                new[] { "application/json" });

            ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(odataRequestOptions));

            Assert.Equal(ExceptionMessage.ODataVersionNotSupported(odataRequestOptions.ODataVersion, odataServiceOptions.MinVersion, odataServiceOptions.MaxVersion), odataException.Message);
            Assert.Equal(HttpStatusCode.BadRequest, odataException.StatusCode);
            Assert.Equal(ODataRequestHeaderNames.ODataVersion, odataException.Target);
        }