mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-07 21:30:13 +00:00
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
|
|
namespace BinaryObjectScanner.Test
|
|
{
|
|
public class EnumerableExtensionsTests
|
|
{
|
|
[Fact]
|
|
public void IterateWithAction_EmptyEnumerable_Success()
|
|
{
|
|
List<string> set = new List<string>();
|
|
Action<string> action = (s) => s.ToLowerInvariant();
|
|
|
|
set.IterateWithAction(action);
|
|
Assert.Empty(set);
|
|
}
|
|
|
|
[Fact]
|
|
public void IterateWithAction_EmptyAction_Success()
|
|
{
|
|
List<string> set = ["a", "b", "c"];
|
|
Action<string> action = (s) => { };
|
|
|
|
set.IterateWithAction(action);
|
|
Assert.Equal(3, set.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void IterateWithAction_Valid_Success()
|
|
{
|
|
List<string> set = ["a", "b", "c"];
|
|
List<string> actual = new List<string>();
|
|
|
|
Action<string> action = (s) =>
|
|
{
|
|
lock (actual)
|
|
{
|
|
actual.Add(s.ToUpperInvariant());
|
|
}
|
|
};
|
|
|
|
set.IterateWithAction(action);
|
|
Assert.Equal(3, set.Count);
|
|
Assert.Equal(3, actual.Count);
|
|
}
|
|
}
|
|
} |