Skip to content

Commit 1963fdd

Browse files
committed
Attempt to fix unit tests
1 parent 1338204 commit 1963fdd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/CommunityToolkit.Maui.UnitTests/Views/DrawingView/DrawingLineTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public async Task GetImageStreamReturnsNullStream()
101101
[Fact(Timeout = (int)TestDuration.Short)]
102102
public async Task GetImageStreamStaticReturnsNullStream()
103103
{
104-
var stream = await DrawingLine.GetImageStream(Array.Empty<PointF>(), new Size(10, 10), 5, Colors.Yellow, Colors.Blue.AsPaint(), CancellationToken.None);
104+
ImagePointOptions pointOptions = new([], new Size(10, 10), 5, Colors.Yellow, Colors.Blue.AsPaint(), null);
105+
var stream = await DrawingLine.GetImageStream(pointOptions, CancellationToken.None);
105106
Assert.Equal(Stream.Null, stream);
106107
}
107108

src/CommunityToolkit.Maui.UnitTests/Views/DrawingView/DrawingViewTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ public async Task GetImageStream_CancellationTokenExpired()
159159
// Ensure CancellationToken Expired
160160
await Task.Delay(100, CancellationToken.None);
161161

162-
await Assert.ThrowsAsync<OperationCanceledException>(async () => await DrawingView.GetImageStream([new DrawingLine()], Size.Zero, Colors.Blue, cts.Token));
162+
ImageLineOptions options = ImageLineOptions.JustLines([new DrawingLine()], Size.Zero, Colors.Transparent.AsPaint());
163+
164+
await Assert.ThrowsAsync<OperationCanceledException>(async () => await DrawingView.GetImageStream(options, cts.Token));
163165
}
164166

165167
[Fact(Timeout = (int)TestDuration.Short)]
@@ -170,9 +172,9 @@ public async Task GetImageStream_CancellationTokenCanceled()
170172
// Ensure CancellationToken Expired
171173
await cts.CancelAsync();
172174

173-
await Assert.ThrowsAsync<OperationCanceledException>(async () => await DrawingView.GetImageStream([
174-
new DrawingLine()
175-
], Size.Zero, Colors.Blue, cts.Token));
175+
ImageLineOptions options = ImageLineOptions.JustLines([new DrawingLine()], Size.Zero, Colors.Transparent.AsPaint());
176+
177+
await Assert.ThrowsAsync<OperationCanceledException>(async () => await DrawingView.GetImageStream(options, cts.Token));
176178
}
177179

178180
[Fact(Timeout = (int)TestDuration.Short)]
@@ -187,9 +189,8 @@ public async Task GetImageStreamReturnsNullStream()
187189
[Fact(Timeout = (int)TestDuration.Short)]
188190
public async Task GetImageStreamStaticReturnsNullStream()
189191
{
190-
var stream = await DrawingView.GetImageStream([
191-
new DrawingLine()
192-
], Size.Zero, Colors.Blue, CancellationToken.None);
192+
ImageLineOptions options = ImageLineOptions.JustLines([new DrawingLine()], Size.Zero, Colors.Blue.AsPaint());
193+
var stream = await DrawingView.GetImageStream(options, CancellationToken.None);
193194
stream.Should().BeSameAs(Stream.Null);
194195
}
195196

0 commit comments

Comments
 (0)