diff --git a/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs b/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs new file mode 100644 index 00000000..3caf5115 --- /dev/null +++ b/BinaryObjectScanner.Test/EnumerableExtensionsTests.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using Xunit; + +namespace BinaryObjectScanner.Tests +{ + public class EnumerableExtensionsTests + { + [Fact] + public void IterateWithAction_EmptyEnumerable_Success() + { + List set = new List(); + Action action = (s) => s.ToLowerInvariant(); + + set.IterateWithAction(action); + Assert.Empty(set); + } + + [Fact] + public void IterateWithAction_EmptyAction_Success() + { + List set = ["a", "b", "c"]; + Action action = (s) => { }; + + set.IterateWithAction(action); + Assert.Equal(3, set.Count); + } + + [Fact] + public void IterateWithAction_Valid_Success() + { + List set = ["a", "b", "c"]; + List actual = new List(); + + Action action = (s) => + { + lock (actual) + { + actual.Add(s.ToUpperInvariant()); + } + }; + + set.IterateWithAction(action); + Assert.Equal(3, set.Count); + Assert.Equal(3, actual.Count); + } + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/BinaryObjectScanner.csproj b/BinaryObjectScanner/BinaryObjectScanner.csproj index 91312af5..bdc5ba95 100644 --- a/BinaryObjectScanner/BinaryObjectScanner.csproj +++ b/BinaryObjectScanner/BinaryObjectScanner.csproj @@ -67,6 +67,25 @@ + + + + + + + + + + + + + + + + + + +