@@ -121,7 +121,6 @@ public void DeleteEntryTests(bool permanent)
121121
122122 }
123123
124-
125124 [ Fact ]
126125 public void DeleteEmptyGroupTest ( )
127126 {
@@ -240,8 +239,143 @@ public void CurrentPathTests()
240239 Debug . WriteLine ( $ "Current path is { passxyz . PxDb . CurrentPath } .") ;
241240 Assert . NotNull ( passxyz . PxDb . CurrentPath ) ;
242241 }
242+
243+ [ Theory ]
244+ [ InlineData ( "/utdb" ) ]
245+ [ InlineData ( "/utdb/General/G1" ) ]
246+ /// <summary>
247+ /// IsParentGroup test cases
248+ /// source: "/utdb/Windows/W1/W2/W3/W4/W5"
249+ /// destination: "/utdb/General/G1/G21"
250+ /// </summary>
251+ /// <param name="path">Source path. Must not be <c>null</c>.</param>
252+ public void IsParentGroupG1Tests ( string path )
253+ {
254+ var dstPath = "/utdb/General/G1" ;
255+ var dstGroup = passxyz . PxDb . FindByPath < PwGroup > ( dstPath ) ;
256+ var srcGroup = passxyz . PxDb . FindByPath < PwGroup > ( path ) ;
257+ if ( passxyz . PxDb . IsParentGroup ( srcGroup , dstGroup ) )
258+ {
259+ Debug . WriteLine ( $ "{ path } is the parent of { dstPath } .") ;
260+ Assert . Equal ( "/utdb" , path ) ;
261+ }
262+ else
263+ {
264+ Debug . WriteLine ( $ "{ path } is not the parent of { dstPath } .") ;
265+ Assert . Equal ( "/utdb/General/G1" , path ) ;
266+ }
267+ }
268+
269+ [ Theory ]
270+ [ InlineData ( "/utdb/Windows/W1" ) ]
271+ [ InlineData ( "/utdb/General" ) ]
272+ /// <summary>
273+ /// IsParentGroup test cases
274+ /// source: "/utdb/Windows/W1/W2/W3/W4/W5"
275+ /// destination: "/utdb/General/G1/G21"
276+ /// </summary>
277+ /// <param name="path">Source path. Must not be <c>null</c>.</param>
278+ public void IsParentGroupG21Tests ( string path )
279+ {
280+ var dstPath = "/utdb/General/G1/G21" ;
281+ var dstGroup = passxyz . PxDb . FindByPath < PwGroup > ( dstPath ) ;
282+ var srcGroup = passxyz . PxDb . FindByPath < PwGroup > ( path ) ;
283+ if ( passxyz . PxDb . IsParentGroup ( srcGroup , dstGroup ) )
284+ {
285+ Debug . WriteLine ( $ "{ path } is the parent of { dstPath } .") ;
286+ Assert . Equal ( "/utdb/General" , path ) ;
287+ }
288+ else
289+ {
290+ Debug . WriteLine ( $ "{ path } is not the parent of { dstPath } .") ;
291+ Assert . Equal ( "/utdb/Windows/W1" , path ) ;
292+ }
293+ }
294+
295+ [ Theory ]
296+ [ InlineData ( "/utdb/General" ) ]
297+ [ InlineData ( "/utdb" ) ]
298+ /// <summary>
299+ /// MoveEntry test cases
300+ /// Test case 1: srcEntry: "/utdb/General", dstGroup: "/utdb/General"
301+ /// Test case 2: srcEntry: "/utdb/TestEntry", dstGroup: "/utdb"
302+ /// </summary>
303+ /// <param name="path">Destination path. Must not be <c>null</c>.</param>
304+ public void MoveEntryTests ( string path )
305+ {
306+ string srcPath ;
307+
308+ if ( path == "/utdb/General" )
309+ {
310+ srcPath = "/utdb/General" ;
311+ }
312+ else
313+ {
314+ srcPath = "/utdb/TestEntry" ;
315+ }
316+
317+ var srcEntry = passxyz . PxDb . FindByPath < PwEntry > ( srcPath ) ;
318+ var dstGroup = passxyz . PxDb . FindByPath < PwGroup > ( path ) ;
319+
320+ if ( passxyz . PxDb . MoveEntry ( srcEntry , dstGroup ) )
321+ {
322+ Debug . WriteLine ( $ "Moved entry { srcPath } to { path } .") ;
323+ Assert . Equal ( "/utdb/General" , path ) ;
324+ }
325+ else
326+ {
327+ Debug . WriteLine ( $ "Cannot move { srcPath } to { path } .") ;
328+ Assert . Equal ( "/utdb" , path ) ;
329+ }
330+ }
331+
332+ [ Theory ]
333+ [ InlineData ( "/utdb/Windows/W1/W2/W3/" ) ]
334+ [ InlineData ( "/utdb/General/G1/G21/" ) ]
335+ [ InlineData ( "/utdb/General/" ) ]
336+ /// <summary>
337+ /// MoveGroup test cases
338+ /// Test case 1: srcGroup: "/utdb/Windows/W1/W2/W3/W4/W5/", dstGroup: "/utdb/Windows/W1/W2/W3/"
339+ /// Move sub-group to the parent group, this is a successful case
340+ /// Test case 2: srcGroup: "/utdb/General/", dstGroup: "/utdb/General/G1/G21/"
341+ /// Move parent group to the sub-group, this is a failure case
342+ /// Test case 2: srcGroup: "/utdb/General/", dstGroup: "/utdb/General/"
343+ /// Move group to the same location, this is a failure case
344+ /// </summary>
345+ /// <param name="path">Destination path. Must not be <c>null</c>.</param>
346+ public void MoveGroupTests ( string path )
347+ {
348+ string srcPath ;
349+
350+ if ( path == "/utdb/General/" )
351+ {
352+ srcPath = "/utdb/General/" ;
353+ }
354+ else if ( path == "/utdb/General/G1/G21/" )
355+ {
356+ srcPath = "/utdb/General/" ;
357+ }
358+ else
359+ {
360+ srcPath = "/utdb/Windows/W1/W2/W3/W4/W5/" ;
361+ }
362+
363+ var srcGroup = passxyz . PxDb . FindByPath < PwGroup > ( srcPath ) ;
364+ var dstGroup = passxyz . PxDb . FindByPath < PwGroup > ( path ) ;
365+
366+ if ( passxyz . PxDb . MoveGroup ( srcGroup , dstGroup ) )
367+ {
368+ Debug . WriteLine ( $ "Moved entry { srcPath } to { path } .") ;
369+ Assert . Equal ( "/utdb/Windows/W1/W2/W3/" , path ) ;
370+ }
371+ else
372+ {
373+ Debug . WriteLine ( $ "Cannot move { srcPath } to { path } .") ;
374+ }
375+ }
243376 }
244377
378+
245379 public class PxLibInfoTests
246380 {
247381 [ Fact ]
0 commit comments