22using Nest . Tests . MockData . Domain ;
33using System . Linq ;
44using Elasticsearch . Net ;
5+ using FluentAssertions ;
56
67namespace Nest . Tests . Integration . Core
78{
@@ -16,26 +17,42 @@ public void TestValidation()
1617 . Term ( f=> f . Country , "netherlands" )
1718 )
1819 ) ;
19- Assert . NotNull ( response ) ;
20- Assert . True ( response . IsValid ) ;
21- Assert . True ( response . Valid ) ;
20+ response . Should ( ) . NotBeNull ( ) ;
21+ response . IsValid . Should ( ) . BeTrue ( ) ;
22+ response . Valid . Should ( ) . BeTrue ( ) ;
2223 }
2324 [ Test ]
24- public void TestValidationWithExplain ( )
25+ public void TestValidationWithExplain_Invalid ( )
2526 {
2627 var response = this . Client . Validate < ElasticsearchProject > ( q => q
2728 . Explain ( )
2829 . Q ( "loc:asdasd" )
2930 ) ;
30- Assert . NotNull ( response ) ;
31- Assert . True ( response . IsValid ) ;
32- Assert . False ( response . Valid ) ;
33- Assert . NotNull ( response . Explanations ) ;
34- Assert . True ( response . Explanations . HasAny ( ) ) ;
31+ response . Should ( ) . NotBeNull ( ) ;
32+ response . IsValid . Should ( ) . BeTrue ( ) ;
33+ response . Valid . Should ( ) . BeFalse ( ) ;
34+ response . Explanations . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
3535 var explanation = response . Explanations . First ( ) ;
36- Assert . AreEqual ( explanation . Index , Settings . DefaultIndex ) ;
37- Assert . False ( explanation . Valid ) ;
38- Assert . False ( explanation . Error . IsNullOrEmpty ( ) ) ;
36+ explanation . Index . Should ( ) . BeEquivalentTo ( Settings . DefaultIndex ) ;
37+ explanation . Valid . Should ( ) . BeFalse ( ) ;
38+ explanation . Error . Should ( ) . NotBeNullOrEmpty ( ) ;
39+ }
40+
41+ [ Test ]
42+ public void TestValidationWithExplanation_Valid ( )
43+ {
44+ var response = this . Client . Validate < ElasticsearchProject > ( v => v
45+ . Explain ( )
46+ . Q ( "name:elasticsearch" )
47+ ) ;
48+ response . Should ( ) . NotBeNull ( ) ;
49+ response . IsValid . Should ( ) . BeTrue ( ) ;
50+ response . Explanations . Should ( ) . NotBeNull ( ) . And . NotBeEmpty ( ) ;
51+ var explanation = response . Explanations . First ( ) ;
52+ explanation . Index . Should ( ) . BeEquivalentTo ( Settings . DefaultIndex ) ;
53+ explanation . Valid . Should ( ) . BeTrue ( ) ;
54+ explanation . Error . Should ( ) . BeNullOrEmpty ( ) ;
55+ explanation . Explanation . Should ( ) . NotBeNullOrEmpty ( ) ;
3956 }
4057 }
4158}
0 commit comments