Skip to content

Commit d8d3d07

Browse files
committed
Cast stream.Position to int in Assert.HasCount calls
Updated all usages of Assert.HasCount to explicitly cast stream.Position to int. This ensures type consistency and prevents potential issues when stream.Position is a long.
1 parent 12ae36b commit d8d3d07

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

tests/CommunityToolkit.HighPerformance.UnitTests/Streams/Test_MemoryStream.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ public void Test_MemoryStream_WriteToEndAndRefreshPosition()
9191
Assert.AreEqual(stream.Position, i + 1);
9292
}
9393

94-
Assert.HasCount(stream.Position, array);
94+
Assert.HasCount((int)stream.Position, array);
9595

9696
// These should not throw, seeking to the end is valid
9797
stream.Position = stream.Position;
98-
Assert.HasCount(stream.Position, array);
98+
Assert.HasCount((int)stream.Position, array);
9999

100100
_ = stream.Seek(array.Length, SeekOrigin.Begin);
101-
Assert.HasCount(stream.Position, array);
101+
Assert.HasCount((int)stream.Position, array);
102102

103103
_ = stream.Seek(0, SeekOrigin.Current);
104-
Assert.HasCount(stream.Position, array);
104+
Assert.HasCount((int)stream.Position, array);
105105

106106
_ = stream.Seek(0, SeekOrigin.End);
107-
Assert.HasCount(stream.Position, array);
107+
Assert.HasCount((int)stream.Position, array);
108108
}
109109

110110
[TestMethod]
@@ -116,7 +116,7 @@ public void Test_MemoryStream_ReadWrite_Array()
116116

117117
stream.Write(data, 0, data.Length);
118118

119-
Assert.HasCount(stream.Position, data);
119+
Assert.HasCount((int)stream.Position, data);
120120

121121
stream.Position = 0;
122122

@@ -125,7 +125,7 @@ public void Test_MemoryStream_ReadWrite_Array()
125125
int bytesRead = stream.Read(result, 0, result.Length);
126126

127127
Assert.HasCount(bytesRead, result);
128-
Assert.HasCount(stream.Position, data);
128+
Assert.HasCount((int)stream.Position, data);
129129
Assert.IsTrue(data.AsSpan().SequenceEqual(result));
130130

131131
_ = Assert.ThrowsExactly<ArgumentNullException>(() => stream.Write(null!, 0, 10));
@@ -148,7 +148,7 @@ public async Task Test_MemoryStream_ReadWriteAsync_Array()
148148

149149
await stream.WriteAsync(data, 0, data.Length);
150150

151-
Assert.HasCount(stream.Position, data);
151+
Assert.HasCount((int)stream.Position, data);
152152

153153
stream.Position = 0;
154154

@@ -157,7 +157,7 @@ public async Task Test_MemoryStream_ReadWriteAsync_Array()
157157
int bytesRead = await stream.ReadAsync(result, 0, result.Length);
158158

159159
Assert.HasCount(bytesRead, result);
160-
Assert.HasCount(stream.Position, data);
160+
Assert.HasCount((int)stream.Position, data);
161161
Assert.IsTrue(data.AsSpan().SequenceEqual(result));
162162

163163
_ = await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => stream.WriteAsync(null!, 0, 10));

0 commit comments

Comments
 (0)