Closed tomhreb closed 1 year ago
I think the message you test for is too specific. It is very easy to break that. Perhaps you can just check for "_id"?
I think the message you test for is too specific. It is very easy to break that. Perhaps you can just check for "_id"?
I am afraid that checking for "_id" only is not enough, for example when someone creates custom index with "_id" in its name.
Thoughts on the following slightly less verbose check?
&& w.WriteError.Category == ServerErrorCategory.DuplicateKey
&& w.WriteError.Message.Contains("index: _id_ ", StringComparison.Ordinal)
ok, changed.
@SebastianStehle what do you think now, will you merge it? Would you like more tests, or?
I want to step back, so it is up to @wassim-k to decide
good work @tomhreb, can you please just bump the version number in the csproj file and we'll get it merged.
@wassim-k done
Hi!
I have not found better way for detecting which field constraint was violated than "parsing" the exception message.
I've added couple test methods into the test host, as it does not seem there is a unit test approach for the persistence provider.