public async Task WriteToStreamAsync_ThrowsArgumentNull_Model() { // Arrange & Act & Assert await ExceptionAssert.ThrowsAsync <InvalidOperationException>( () => ODataOutputFormatterHelper.WriteToStreamAsync(null, null, null, ODataVersion.V4, null, null, null, null, null), "The request must have an associated EDM model. Consider registering Edm model calling AddOData()."); }
public void GetSerializer_ThrowsSerializationException_NonEdmType() { // Arrange Mock <IEdmObject> mock = new Mock <IEdmObject>(); mock.Setup(s => s.GetEdmType()).Returns((IEdmTypeReference)null); // Act & Assert ExceptionAssert.Throws <SerializationException>(() => ODataOutputFormatterHelper.GetSerializer(type: null, mock.Object, null, null), "The EDM type of the object of type 'Castle.Proxies.IEdmObjectProxy' is null. The EDM type of an 'IEdmObject' cannot be null."); }
public void GetSerializer_ThrowsSerializationException_TypeCannotBeSerialized() { // Arrange Type intType = typeof(int); HttpRequest request = new DefaultHttpContext().Request; Mock <ODataSerializerProvider> provider = new Mock <ODataSerializerProvider>(); provider.Setup(s => s.GetODataPayloadSerializer(intType, request)).Returns((ODataSerializer)null); // Act & Assert ExceptionAssert.Throws <SerializationException>( () => ODataOutputFormatterHelper.GetSerializer(intType, null, request, provider.Object), "'Int32' cannot be serialized using the OData output formatter."); }
public void GetSerializer_ThrowsSerializationException_TypeCannotBeSerialized_NonClrType() { // Arrange IEdmTypeReference intType = EdmCoreModel.Instance.GetInt32(false); Mock <IEdmObject> mock = new Mock <IEdmObject>(); mock.Setup(s => s.GetEdmType()).Returns(intType); Mock <ODataSerializerProvider> provider = new Mock <ODataSerializerProvider>(); provider.Setup(s => s.GetEdmTypeSerializer(intType)).Returns((ODataEdmTypeSerializer)null); // Act & Assert ExceptionAssert.Throws <SerializationException>( () => ODataOutputFormatterHelper.GetSerializer(null, mock.Object, null, provider.Object), "'[Edm.Int32 Nullable=False]' cannot be serialized using the OData output formatter."); }
public void BuildSerializerContext_ThrowsArgumentNull_Request() { // Arrange & Act & Assert ExceptionAssert.ThrowsArgumentNull(() => ODataOutputFormatterHelper.BuildSerializerContext(null), "request"); }