@@ -18,7 +18,9 @@ public DbSessionTest(SmartSqlFixture smartSqlFixture)
1818 {
1919 SqlMapper = smartSqlFixture . SqlMapper ;
2020 }
21+
2122 #region Insert_From_RealSql
23+
2224 private const string INSERT_SQL = @"INSERT INTO T_AllPrimitive
2325 (Boolean
2426 ,[Char]
@@ -76,6 +78,7 @@ public DbSessionTest(SmartSqlFixture smartSqlFixture)
7678 ,@NullableNumericalEnum
7779 ,@NullableString);
7880 Select SCOPE_IDENTITY();" ;
81+
7982 [ Fact ]
8083 public void Insert_From_RealSql ( )
8184 {
@@ -89,6 +92,7 @@ public void Insert_From_RealSql()
8992 }
9093 } ) ;
9194 }
95+
9296 #endregion
9397
9498 [ Fact ]
@@ -105,6 +109,7 @@ public void Insert()
105109 }
106110 } ) ;
107111 }
112+
108113 [ Fact ]
109114 public void InsertByRequestTransaction ( )
110115 {
@@ -120,6 +125,7 @@ public void InsertByRequestTransaction()
120125 }
121126 } ) ;
122127 }
128+
123129 [ Fact ]
124130 public void InsertByStatementTransaction ( )
125131 {
@@ -134,21 +140,40 @@ public void InsertByStatementTransaction()
134140 }
135141 } ) ;
136142 }
143+
137144 [ Fact ]
138145 public void InsertByIdGen ( )
139146 {
147+ var entity = new AllPrimitive
148+ {
149+ DateTime = DateTime . Now ,
150+ String = "SmartSql" ,
151+ } ;
140152 var id = SqlMapper . ExecuteScalar < long > ( new RequestContext
141153 {
142154 Scope = nameof ( AllPrimitive ) ,
143155 SqlId = "InsertByIdGen" ,
144- Request = new AllPrimitive
145- {
146- DateTime = DateTime . Now ,
147- String = "SmartSql" ,
148- }
156+ Request = entity
149157 } ) ;
150158 }
151159
160+ [ Fact ]
161+ public void InsertByIdGenAssignId ( )
162+ {
163+ var entity = new AllPrimitive
164+ {
165+ DateTime = DateTime . Now ,
166+ String = "SmartSql" ,
167+ } ;
168+ var affected = SqlMapper . Execute ( new RequestContext
169+ {
170+ Scope = nameof ( AllPrimitive ) ,
171+ SqlId = "InsertByIdGenAssignId" ,
172+ Request = entity
173+ } ) ;
174+ Assert . True ( entity . Int64 > 0 ) ;
175+ }
176+
152177 [ Fact ]
153178 public async Task QueryAsync ( )
154179 {
@@ -207,6 +232,7 @@ public void Update()
207232 }
208233 } ) ;
209234 }
235+
210236 //[Fact]
211237 public void Delete ( )
212238 {
@@ -221,6 +247,7 @@ public void Delete()
221247 }
222248 } ) ;
223249 }
250+
224251 [ Fact ]
225252 public void DeleteCheckIncludeRequired ( )
226253 {
@@ -238,6 +265,7 @@ public void DeleteCheckIncludeRequired()
238265 Assert . True ( true ) ;
239266 }
240267 }
268+
241269 [ Fact ]
242270 public void DeleteCheckIsNotEmptyRequired ( )
243271 {
@@ -257,8 +285,6 @@ public void DeleteCheckIsNotEmptyRequired()
257285 }
258286
259287
260-
261-
262288 //Create PROCEDURE[dbo].[SP_QueryUser]
263289 //@Total int = 0 Out
264290 // AS
@@ -287,6 +313,5 @@ public void SP()
287313 var list = SqlMapper . Query < User > ( context ) ;
288314 dbParameterCollection . TryGetParameterValue ( "Total" , out int total ) ;
289315 }
290-
291316 }
292- }
317+ }
0 commit comments