11using System . Threading . Tasks ;
22using FluentAssertions ;
3+ using PortaCapena . OdooJsonRpcClient . Consts ;
34using PortaCapena . OdooJsonRpcClient . Shared ;
45using PortaCapena . OdooJsonRpcClient . Shared . Models ;
56using Xunit ;
@@ -8,7 +9,7 @@ namespace PortaCapena.OdooJsonRpcClient.Example
89{
910 public class CompanyOdooRepository : TestBase
1011 {
11- public class CompanyRepository : OdooRepository < ResCompanyOdooModel >
12+ private class CompanyRepository : OdooRepository < ResCompanyOdooModel >
1213 {
1314 public CompanyRepository ( ) : base ( Config ) { }
1415 }
@@ -24,5 +25,66 @@ public async Task Get_All()
2425 result . Succeed . Should ( ) . BeTrue ( ) ;
2526 result . Value . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
2627 }
28+
29+ [ Fact ]
30+ public async Task Get_By_Id ( )
31+ {
32+ var repo = new CompanyRepository ( ) ;
33+
34+ var result = await repo . Query ( ) . ById ( 1 ) . FirstOrDefaultAsync ( ) ;
35+
36+ result . Error . Should ( ) . BeNull ( ) ;
37+ result . Succeed . Should ( ) . BeTrue ( ) ;
38+ result . Value . Should ( ) . NotBeNull ( ) ;
39+ }
40+
41+ [ Fact ]
42+ public async Task Get_By_Ids ( )
43+ {
44+ var repo = new CompanyRepository ( ) ;
45+
46+ var result = await repo . Query ( ) . ByIds ( 1 , 2 ) . ToListAsync ( ) ;
47+
48+ result . Error . Should ( ) . BeNull ( ) ;
49+ result . Succeed . Should ( ) . BeTrue ( ) ;
50+ result . Value . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
51+ result . Value . Length . Should ( ) . Be ( 2 ) ;
52+ }
53+
54+ [ Fact ]
55+ public async Task Get_By_Name ( )
56+ {
57+ var repo = new CompanyRepository ( ) ;
58+
59+ var result = await repo . Query ( ) . Where ( x => x . Name , OdooOperator . EqualsTo , "My Company" ) . FirstOrDefaultAsync ( ) ;
60+
61+ result . Error . Should ( ) . BeNull ( ) ;
62+ result . Succeed . Should ( ) . BeTrue ( ) ;
63+ result . Value . Should ( ) . NotBeNull ( ) ;
64+ }
65+
66+ [ Fact ]
67+ public async Task Get_By_Country ( )
68+ {
69+ var repo = new CompanyRepository ( ) ;
70+
71+ var result = await repo . Query ( ) . Where ( x => x . CountryCode , OdooOperator . EqualsTo , "BE" ) . ToListAsync ( ) ;
72+
73+ result . Error . Should ( ) . BeNull ( ) ;
74+ result . Succeed . Should ( ) . BeTrue ( ) ;
75+ result . Value . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
76+ }
77+
78+ [ Fact ]
79+ public async Task Get_By_Country_name ( )
80+ {
81+ var repo = new CompanyRepository ( ) ;
82+
83+ var result = await repo . Query ( ) . Where < ResCountryOdooModel > ( x => x . CountryId , x => x . Name , OdooOperator . EqualsTo , "Belgium" ) . ToListAsync ( ) ;
84+
85+ result . Error . Should ( ) . BeNull ( ) ;
86+ result . Succeed . Should ( ) . BeTrue ( ) ;
87+ result . Value . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
88+ }
2789 }
2890}
0 commit comments