1+ using FluentAssertions ;
2+ using Xunit ;
3+
4+ namespace LiteDB . Tests . Issues ;
5+
6+ public class Issue2570_Tests
7+ {
8+ public class Person
9+ {
10+ public int Id { get ; set ; }
11+
12+ public ( string FirstName , string LastName ) Name { get ; set ; }
13+ }
14+
15+ [ Fact ]
16+ public void Issue2570_Tuples ( )
17+ {
18+ using ( var db = new LiteDatabase ( ":memory:" ) )
19+ {
20+ var col = db . GetCollection < Person > ( "Person" ) ;
21+
22+ col . Insert ( new Person { Name = ( "John" , "Doe" ) } ) ;
23+ col . Insert ( new Person { Name = ( "Joana" , "Doe" ) } ) ;
24+
25+ var result = col . FindOne ( x => x . Name . FirstName == "John" ) ;
26+
27+ result . Should ( ) . NotBeNull ( ) ;
28+ result . Name . FirstName . Should ( ) . Be ( "John" ) ;
29+ result . Name . LastName . Should ( ) . Be ( "Doe" ) ;
30+ }
31+ }
32+
33+ public struct PersonData
34+ {
35+ public string FirstName ;
36+ public string LastName ;
37+ }
38+
39+ public class PersonWithStruct
40+ {
41+ public int Id { get ; set ; }
42+
43+ public PersonData Name { get ; set ; }
44+ }
45+
46+ [ Fact ]
47+ public void Issue2570_Structs ( )
48+ {
49+ using ( var db = new LiteDatabase ( ":memory:" ) )
50+ {
51+ var col = db . GetCollection < PersonWithStruct > ( "Person" ) ;
52+
53+ col . Insert ( new PersonWithStruct { Name = new PersonData { FirstName = "John" , LastName = "Doe" } } ) ;
54+ col . Insert ( new PersonWithStruct { Name = new PersonData { FirstName = "Joana" , LastName = "Doe" } } ) ;
55+
56+ var result = col . FindOne ( x => x . Name . FirstName == "John" ) ;
57+
58+ result . Should ( ) . NotBeNull ( ) ;
59+ result . Name . FirstName . Should ( ) . Be ( "John" ) ;
60+ result . Name . LastName . Should ( ) . Be ( "Doe" ) ;
61+ }
62+ }
63+ }
0 commit comments