-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CosmosSerializer and CosmosSerializationOptions in the Cosmos Provider #24334
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,34 @@ public async Task Should_throw_if_specified_connection_mode_is_wrong() | |
}); | ||
} | ||
|
||
[ConditionalFact] | ||
public async Task Should_use_serialization_options() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is just for example. I actually don't know where I should put tests for this. |
||
{ | ||
var serializationOptions = new CosmosSerializationOptions | ||
{ | ||
IgnoreNullValues = true | ||
}; | ||
|
||
await using var testDatabase = CosmosTestStore.CreateInitialized(DatabaseName, o => | ||
{ | ||
o.SerializationOptions(serializationOptions); | ||
}); | ||
var options = CreateOptions(testDatabase); | ||
|
||
var customer = new Customer { Id = 43 }; | ||
|
||
using var context = new CustomerContext(options); | ||
context.Database.EnsureCreated(); | ||
|
||
context.Add(customer); | ||
|
||
context.SaveChanges(); | ||
|
||
var customerEntry = context.Entry(context.Find<Customer>(customer.Id)); | ||
var jsonProperty = customerEntry.Property<string>("Name"); | ||
Assert.Null(jsonProperty); | ||
} | ||
|
||
private DbContextOptions CreateOptions(CosmosTestStore testDatabase) | ||
=> Fixture.AddOptions(testDatabase.AddProviderOptions(new DbContextOptionsBuilder())) | ||
.EnableDetailedErrors() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this code. can anyone explain how to implement it in a proper way?