8
8
//------------------------------------------------------------------------------
9
9
10
10
11
+ using Lucene . Net . Util ;
12
+
11
13
namespace NHibernate . Search . Tests . Query
12
14
{
13
15
using System ;
@@ -44,16 +46,15 @@ protected override IEnumerable<string> Mappings
44
46
//{
45
47
//}
46
48
47
- [ Test , Explicit ]
49
+ [ Test ]
48
50
public async Task ResultTransformToDelimStringAsync ( )
49
51
{
50
- IFullTextSession s = Search . CreateFullTextSession ( this . OpenSession ( ) ) ;
51
- await ( this . PrepEmployeeIndexAsync ( s ) ) ;
52
+ IFullTextSession s = Search . CreateFullTextSession ( OpenSession ( ) ) ;
53
+ await ( PrepEmployeeIndexAsync ( s ) ) ;
52
54
53
55
s . Clear ( ) ;
54
56
ITransaction tx = s . BeginTransaction ( ) ;
55
- QueryParser parser = new QueryParser ( Lucene . Net . Util . LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( Lucene . Net . Util . LuceneVersion . LUCENE_48 ) ) ;
56
-
57
+ QueryParser parser = new QueryParser ( LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( LuceneVersion . LUCENE_48 ) ) ;
57
58
Query query = parser . Parse ( "Dept:ITech" ) ;
58
59
IFullTextQuery hibQuery = s . CreateFullTextQuery ( query , typeof ( Employee ) ) ;
59
60
hibQuery . SetProjection (
@@ -66,25 +67,25 @@ public async Task ResultTransformToDelimStringAsync()
66
67
ProjectionConstants . ID ) ;
67
68
hibQuery . SetResultTransformer ( new ProjectionToDelimStringResultTransformer ( ) ) ;
68
69
69
- IList result = await ( hibQuery . ListAsync ( ) ) ;
70
- Assert . IsTrue ( ( ( string ) result [ 0 ] ) . StartsWith ( "1000, Griffin, ITech" ) , "incorrect transformation" ) ;
71
- Assert . IsTrue ( ( ( string ) result [ 1 ] ) . StartsWith ( "1002, Jimenez, ITech" ) , "incorrect transformation" ) ;
70
+ var result = await ( hibQuery . ListAsync < string > ( ) ) ;
71
+ Assert . That ( result [ 3 ] , Does . StartWith ( "1000, Griffin, ITech" ) , "incorrect transformation" ) ;
72
+ Assert . That ( result [ 2 ] , Does . StartWith ( "1002, Jimenez, ITech" ) , "incorrect transformation" ) ;
72
73
73
74
// cleanup
74
75
await ( s . DeleteAsync ( "from System.Object" ) ) ;
75
76
await ( tx . CommitAsync ( ) ) ;
76
77
s . Close ( ) ;
77
78
}
78
79
79
- [ Test , Explicit ]
80
+ [ Test ]
80
81
public async Task ResultTransformMapAsync ( )
81
82
{
82
- IFullTextSession s = Search . CreateFullTextSession ( this . OpenSession ( ) ) ;
83
- await ( this . PrepEmployeeIndexAsync ( s ) ) ;
83
+ IFullTextSession s = Search . CreateFullTextSession ( OpenSession ( ) ) ;
84
+ await ( PrepEmployeeIndexAsync ( s ) ) ;
84
85
85
86
s . Clear ( ) ;
86
87
ITransaction tx = s . BeginTransaction ( ) ;
87
- QueryParser parser = new QueryParser ( Lucene . Net . Util . LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( Lucene . Net . Util . LuceneVersion . LUCENE_48 ) ) ;
88
+ QueryParser parser = new QueryParser ( LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( LuceneVersion . LUCENE_48 ) ) ;
88
89
89
90
Query query = parser . Parse ( "Dept:ITech" ) ;
90
91
IFullTextQuery hibQuery = s . CreateFullTextQuery ( query , typeof ( Employee ) ) ;
@@ -99,8 +100,8 @@ public async Task ResultTransformMapAsync()
99
100
ProjectionConstants . ID ) ;
100
101
hibQuery . SetResultTransformer ( new ProjectionToMapResultTransformer ( ) ) ;
101
102
102
- IList transforms = await ( hibQuery . ListAsync ( ) ) ;
103
- Dictionary < string , object > map = ( Dictionary < string , object > ) transforms [ 1 ] ;
103
+ var transforms = await ( hibQuery . ListAsync < Dictionary < string , object > > ( ) ) ;
104
+ var map = transforms [ 2 ] ;
104
105
105
106
Assert . AreEqual ( "ITech" , map [ "Dept" ] , "incorrect transformation" ) ;
106
107
Assert . AreEqual ( 1002 , map [ "Id" ] , "incorrect transformation" ) ;
@@ -119,12 +120,12 @@ public async Task ResultTransformMapAsync()
119
120
[ Test ]
120
121
public async Task LuceneObjectsProjectionWithIterateAsync ( )
121
122
{
122
- IFullTextSession s = Search . CreateFullTextSession ( this . OpenSession ( ) ) ;
123
- await ( this . PrepEmployeeIndexAsync ( s ) ) ;
123
+ IFullTextSession s = Search . CreateFullTextSession ( OpenSession ( ) ) ;
124
+ await ( PrepEmployeeIndexAsync ( s ) ) ;
124
125
125
126
s . Clear ( ) ;
126
127
ITransaction tx = s . BeginTransaction ( ) ;
127
- QueryParser parser = new QueryParser ( Lucene . Net . Util . LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( Lucene . Net . Util . LuceneVersion . LUCENE_48 ) ) ;
128
+ QueryParser parser = new QueryParser ( LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( LuceneVersion . LUCENE_48 ) ) ;
128
129
129
130
Query query = parser . Parse ( "Dept:ITech" ) ;
130
131
IFullTextQuery hibQuery = s . CreateFullTextQuery ( query , typeof ( Employee ) ) ;
@@ -162,12 +163,12 @@ public async Task LuceneObjectsProjectionWithIterateAsync()
162
163
[ Test ]
163
164
public async Task LuceneObjectsProjectionWithListAsync ( )
164
165
{
165
- IFullTextSession s = Search . CreateFullTextSession ( this . OpenSession ( ) ) ;
166
- await ( this . PrepEmployeeIndexAsync ( s ) ) ;
166
+ IFullTextSession s = Search . CreateFullTextSession ( OpenSession ( ) ) ;
167
+ await ( PrepEmployeeIndexAsync ( s ) ) ;
167
168
168
169
s . Clear ( ) ;
169
170
ITransaction tx = s . BeginTransaction ( ) ;
170
- QueryParser parser = new QueryParser ( Lucene . Net . Util . LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( Lucene . Net . Util . LuceneVersion . LUCENE_48 ) ) ;
171
+ QueryParser parser = new QueryParser ( LuceneVersion . LUCENE_48 , "Dept" , new StandardAnalyzer ( LuceneVersion . LUCENE_48 ) ) ;
171
172
172
173
Query query = parser . Parse ( "Dept:Accounting" ) ;
173
174
IFullTextQuery hibQuery = s . CreateFullTextQuery ( query , typeof ( Employee ) ) ;
0 commit comments