Migrate to dotnet8 and fix warnings

This commit is contained in:
2024-02-18 00:46:45 +01:00
parent a688f2a692
commit 66536657e2
15 changed files with 492 additions and 470 deletions

View File

@@ -7,60 +7,75 @@ public class ByteArraySearcherTests
[Fact]
public void Contains__EmptyNeedle_ReturnsTrue()
{
byte[] haystack = { 1, 2, 3, 4, 5 };
// --- Arrange
byte[] haystack = [1, 2, 3, 4, 5,];
byte[] needle = Array.Empty<byte>();
ByteArraySearcher searcher = new(needle);
// --- Act
bool result = searcher.Contains(haystack);
// --- Assert
Assert.True(result);
}
[Fact]
public void Contains__NeedleAtBeginning_ReturnsTrue()
{
byte[] haystack = { 1, 2, 3, 4, 5 };
byte[] needle = { 1, 2, 3 };
// --- Arrange
byte[] haystack = [1, 2, 3, 4, 5,];
byte[] needle = [1, 2, 3,];
ByteArraySearcher searcher = new(needle);
// --- Act
bool result = searcher.Contains(haystack);
// --- Assert
Assert.True(result);
}
[Fact]
public void Contains__NeedleInMiddle_ReturnsTrue()
{
byte[] haystack = { 1, 2, 3, 4, 5 };
byte[] needle = { 3, 4 };
// --- Arrange
byte[] haystack = [1, 2, 3, 4, 5,];
byte[] needle = [3, 4,];
ByteArraySearcher searcher = new(needle);
// --- Act
bool result = searcher.Contains(haystack);
// --- Assert
Assert.True(result);
}
[Fact]
public void Contains__NeedleAtEnd_ReturnsTrue()
{
byte[] haystack = { 1, 2, 3, 4, 5 };
byte[] needle = { 4, 5 };
// --- Arrange
byte[] haystack = [1, 2, 3, 4, 5,];
byte[] needle = [4, 5,];
ByteArraySearcher searcher = new(needle);
// --- Act
bool result = searcher.Contains(haystack);
// --- Assert
Assert.True(result);
}
[Fact]
public void Contains__NeedleNotPresent_ReturnsFalse()
{
byte[] haystack = { 1, 2, 3, 4, 5 };
byte[] needle = { 5, 6, 7 };
// --- Arrange
byte[] haystack = [1, 2, 3, 4, 5,];
byte[] needle = [5, 6, 7,];
ByteArraySearcher searcher = new(needle);
// --- Act
bool result = searcher.Contains(haystack);
// --- Assert
Assert.False(result);
}
}