Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Below is my function for exploding empty groups and removing an item from a group if it is the only item in a group. This function works as expected with the caveat that I have to run it multiple times to remove all the groups. I have tried several solutions including rerunning the test recursively every time a group is removed until it does not return but this still does not work. I think it may have to do with do with items moving around the testdata in the same step(idk). Does anybody have any ideas for a solution or a method to await the testdata refreshing after an item is moved?
void explode_empty_groups()
{
var tests_data = doc_cd.TestsData.Tests;
foreach (ClashTest ctest in tests_data)
{
foreach (SavedItem _item in ctest.Children)
{
if(_item.IsGroup)
{
ClashResultGroup clash_group = _item as ClashResultGroup;
if (clash_group == null)
{
//isgroup & null
doc_cd.TestsData.TestsRemove(ctest, _item);
continue;
}
//move child out
if (clash_group.Children.Count == 1)
{
doc_cd.TestsData.TestsMove(clash_group, 0, ctest, 0);
doc_cd.TestsData.TestsRemove(ctest, clash_group);
continue;
}
//remove group
if (clash_group.Children.Count == 0)
{
doc_cd.TestsData.TestsRemove(ctest, clash_group);
continue;
}
}
}
return;
}
}
Solved! Go to Solution.