Description
The attached repro.cs was used as a basis for developing a full set of related tests. For the actual tests see the changes in master.
The full set of tests uses the following types:
public class C |
{
|
public int Id { get; set; } |
|
|
public E I1 { get; set; } |
public E I2 { get; set; } |
|
|
[BsonRepresentation(BsonType.String)] public E S1 { get; set; } |
[BsonRepresentation(BsonType.String)] public E S2 { get; set; } |
}
|
|
|
public enum E { E1 = 1, E2 } |
The key fact is that I1 and I2 are represented as integers, whereas S1 and S2 are represented as strings.
And the following test cases were added:
// the following cases should use the correct representation in the predicate
|
d => d.I1 == E.E1 ? true : false |
d => d.S1 == E.E1 ? true : false |
d => E.E1 == d.I1 ? true : false |
d => E.E1 == d.S1 ? true : false |
|
|
// the following test case should use the representation from the serializer registry
|
true ? E.E1 : E.E2 |
|
|
// the following test cases should use the representation implied by the predicate for the result
|
d.I1 == E.E1 ? E.E1 : E.E2
|
d.S1 == E.E1 ? E.E1 : E.E2
|
|
|
// the following test cases should use the representation implied by the ifTrue/ifFalse clauses for the result
|
d.I1 == E.E1 ? d.I1 : E.E2
|
d.I1 == E.E1 ? d.I1 : d.I2
|
d.I1 == E.E1 ? d.S1 : E.E2
|
d.I1 == E.E1 ? E.E1 : d.I2
|
d.I1 == E.E1 ? E.E1 : d.S2
|
d.I1 == E.E1 ? d.S1 : d.S2
|
d.S1 == E.E1 ? d.I1 : E.E2
|
d.S1 == E.E1 ? d.I1 : d.I2
|
d.S1 == E.E1 ? d.S1 : E.E2
|
d.S1 == E.E1 ? E.E1 : d.I2
|
d.S1 == E.E1 ? E.E1 : d.S2
|
d.S1 == E.E1 ? d.S1 : d.S2
|
|
|
|
|
// the following test cases should throw because the ifTrue/ifFalse clauses have conflicting representations
|
d.I1 == E.E1 ? d.I1 : d.S2
|
d.I1 == E.E1 ? d.S1 : d.I2
|
Attachments
Issue Links
- related to
-
CSHARP-3315 LINQ3: Serializers should implement Equals
-
- Backlog
-