Skip to content

Commit 3246e60

Browse files
committed
Fix error that list got modified during iteration
1 parent 6131834 commit 3246e60

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Assets/Plugins/StreamChat/Tests/StatefulClient/PollsTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class PollsTests : BaseStateIntegrationTests
2323
{
2424
private readonly List<string> _tempPollIds = new List<string>();
2525

26-
[TearDown]
26+
[OneTimeTearDown]
2727
public async void TearDown()
2828
{
2929
await DeleteTempPollsAsync();
@@ -36,8 +36,10 @@ private async Task DeleteTempPollsAsync()
3636
return;
3737
}
3838

39-
foreach (var pollId in _tempPollIds)
39+
// Iterate in reverse to avoid collection modification issues
40+
for (int i = _tempPollIds.Count - 1; i >= 0; i--)
4041
{
42+
var pollId = _tempPollIds[i];
4143
try
4244
{
4345
await Client.Polls.DeletePollAsync(pollId);

0 commit comments

Comments
 (0)