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); }
public void Validate_ODataRequestOptions_Throws_ODataException_If_ODataMaxVersion_AboveMaxSupported() { var odataRequestOptions = new ODataRequestOptions( new Uri("https://services.odata.org/OData"), ODataIsolationLevel.None, ODataMetadataLevel.Minimal, ODataVersion.OData40, ODataVersion.Parse("5.0")); 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.ODataMaxVersionNotSupported(odataRequestOptions.ODataMaxVersion, odataServiceOptions.MinVersion, odataServiceOptions.MaxVersion), odataException.Message); Assert.Equal(HttpStatusCode.BadRequest, odataException.StatusCode); Assert.Equal(ODataRequestHeaderNames.ODataMaxVersion, odataException.Target); }
public void GetValidator_Throws_NotSupportedException_For_Unsupported_ODataVersion() { Assert.Throws <NotSupportedException>(() => ODataQueryOptionsValidator.GetValidator(ODataVersion.Parse("3.0"))); }
public void CompareTo_Returns_0_IfSameInstance() { Assert.Equal(0, ODataVersion.OData40.CompareTo(ODataVersion.OData40)); Assert.Equal(0, ODataVersion.OData40.CompareTo((object)ODataVersion.OData40)); Assert.Equal(0, ODataVersion.Parse("3.0").CompareTo((object)ODataVersion.Parse("3.0"))); }