This repository was archived by the owner on Apr 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed
NetCoreEntityFramework.Tests Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -211,5 +211,64 @@ public void DeleteWithEmptyGuidThrowsException()
211211 Assert . ThrowsAsync < ArgumentException > ( ( ) => _repository . Delete ( Guid . Empty ) ) ;
212212 }
213213 #endregion
214+
215+ #region Restore
216+ [ Test ]
217+ public async Task RestoreSetsDeletedFalse ( )
218+ {
219+ bool success ;
220+
221+ using ( _repository )
222+ {
223+ success = await _repository . Restore ( _deletedEntity ) ;
224+ }
225+
226+ var restoredEntity = await _repository . Get ( ( Guid ) _deletedEntity . Id ) ;
227+ Assert . IsTrue ( success ) ;
228+ Assert . IsFalse ( restoredEntity ? . Deleted ) ;
229+ }
230+
231+ [ Test ]
232+ public void RestoreThrowsExceptionWhenEntityNull ( )
233+ {
234+ Assert . ThrowsAsync < ArgumentNullException > ( ( ) => _repository . Restore ( null ) ) ;
235+ }
236+
237+ [ Test ]
238+ public async Task RestoreOnIdSetsDeletedFalse ( )
239+ {
240+ bool success ;
241+ Guid id = ( Guid ) _deletedEntity . Id ;
242+
243+ using ( _repository )
244+ {
245+ success = await _repository . Restore ( id ) ;
246+ }
247+
248+ var restoredEntity = await _repository . Get ( id ) ;
249+ Assert . IsTrue ( success ) ;
250+ Assert . IsFalse ( restoredEntity ? . Deleted ) ;
251+ }
252+
253+ [ Test ]
254+ [ AutoData ]
255+ public async Task RestoreOnInvalidIdReturnsFalse ( Guid randomId )
256+ {
257+ bool success ;
258+
259+ using ( _repository )
260+ {
261+ success = await _repository . Restore ( randomId ) ;
262+ }
263+
264+ Assert . IsFalse ( success ) ;
265+ }
266+
267+ [ Test ]
268+ public void RestoreOnEmptyGuidThrowsException ( )
269+ {
270+ Assert . ThrowsAsync < ArgumentException > ( ( ) => _repository . Restore ( Guid . Empty ) ) ;
271+ }
272+ #endregion
214273 }
215274}
You can’t perform that action at this time.
0 commit comments