-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix subtle bug when deserializing property without value
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1553,6 +1553,38 @@ public void ReadAsync_ThrowsOnUnknownEntityType() | |
typeof(Product), _readContext).Wait(), "The property 'Concurrency' does not exist on type 'ODataDemo.Product'. Make sure to only use property names that are defined by the type or mark the type as open type."); | ||
} | ||
|
||
[Fact] | ||
public async Task ReadAsync_ForPropertyWithoutValue() | ||
{ | ||
// Arrange | ||
string content = "{" + | ||
"\"ID\":0," + | ||
"\"Name\":\"Bread\"," + | ||
"\"Description\":\"Whole grain bread\"," + | ||
"\"PublishDate\":\"1997-07-01\"," + | ||
"\"[email protected]\":\"#Edm.DateTimeOffset\"," + // OData annotation - Property without value | ||
"\"[email protected]\":true," + // Custom annotation - Property without value | ||
"\"Rating\":4," + | ||
"\"Price\":2.5" + | ||
"}"; | ||
|
||
ODataResourceDeserializer deserializer = new ODataResourceDeserializer(_deserializerProvider); | ||
|
||
// Act | ||
Product product = await deserializer.ReadAsync( | ||
GetODataMessageReader(content, _edmModel), | ||
typeof(Product), | ||
_readContext) as Product; | ||
|
||
// Assert | ||
Assert.Equal(0, product.ID); | ||
Assert.Equal(4, product.Rating); | ||
Assert.Equal(2.5m, product.Price); | ||
Assert.Equal(product.PublishDate, new Date(1997, 7, 1)); | ||
Assert.Null(product.ReleaseDate); | ||
Assert.Null(product.DiscontinuedDate); | ||
} | ||
|
||
private static ODataMessageReader GetODataMessageReader(IODataRequestMessage oDataRequestMessage, IEdmModel edmModel) | ||
{ | ||
return new ODataMessageReader(oDataRequestMessage, new ODataMessageReaderSettings(), edmModel); | ||
|