Skip to content

Commit 1605e97

Browse files
authored
move await using noise in test project (#1371)
1 parent 4342519 commit 1605e97

File tree

2 files changed

+35
-117
lines changed

2 files changed

+35
-117
lines changed

test/Sentry.Tests/Internals/PartialStreamTests.cs

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ public class PartialStreamTests
88
public async Task PartialStream_WithOffsetAndLength_Length_ReturnsPartialLength()
99
{
1010
// Arrange
11-
#if !NET461 && !NETCOREAPP2_1
12-
await
13-
#endif
14-
using var originalStream = new MemoryStream();
11+
using var originalStream = new MemoryStream();
1512
await originalStream.FillWithRandomBytesAsync(1024);
1613

1714
const int offset = 10;
1815
const int length = 100;
19-
#if !NET461 && !NETCOREAPP2_1
20-
await
21-
#endif
22-
using var partialStream = new PartialStream(originalStream, offset, length);
16+
17+
using var partialStream = new PartialStream(originalStream, offset, length);
2318

2419
// Act & assert
2520
partialStream.Length.Should().Be(length);
@@ -29,24 +24,16 @@ public async Task PartialStream_WithOffsetAndLength_Length_ReturnsPartialLength(
2924
public async Task PartialStream_WithOffsetAndLength_ReadToEnd_ReturnsOnlyDataInRange()
3025
{
3126
// Arrange
32-
#if !NET461 && !NETCOREAPP2_1
33-
await
34-
#endif
35-
using var originalStream = new MemoryStream();
27+
using var originalStream = new MemoryStream();
3628
await originalStream.FillWithRandomBytesAsync(1024);
3729

3830
const int offset = 10;
3931
const int length = 100;
40-
#if !NET461 && !NETCOREAPP2_1
41-
await
42-
#endif
43-
using var partialStream = new PartialStream(originalStream, offset, length);
32+
33+
using var partialStream = new PartialStream(originalStream, offset, length);
4434

4535
// Act
46-
#if !NET461 && !NETCOREAPP2_1
47-
await
48-
#endif
49-
using var outputStream = new MemoryStream();
36+
using var outputStream = new MemoryStream();
5037
await partialStream.CopyToAsync(outputStream);
5138

5239
// Assert
@@ -60,23 +47,15 @@ public async Task PartialStream_WithOffsetAndLength_ReadToEnd_ReturnsOnlyDataInR
6047
public async Task PartialStream_WithOffset_ReadToEnd_ReturnsOnlyDataInRange()
6148
{
6249
// Arrange
63-
#if !NET461 && !NETCOREAPP2_1
64-
await
65-
#endif
66-
using var originalStream = new MemoryStream();
50+
using var originalStream = new MemoryStream();
6751
await originalStream.FillWithRandomBytesAsync(1024);
6852

6953
const int offset = 10;
70-
#if !NET461 && !NETCOREAPP2_1
71-
await
72-
#endif
73-
using var partialStream = new PartialStream(originalStream, offset, null);
54+
55+
using var partialStream = new PartialStream(originalStream, offset, null);
7456

7557
// Act
76-
#if !NET461 && !NETCOREAPP2_1
77-
await
78-
#endif
79-
using var outputStream = new MemoryStream();
58+
using var outputStream = new MemoryStream();
8059
await partialStream.CopyToAsync(outputStream);
8160

8261
// Assert
@@ -90,28 +69,20 @@ public async Task PartialStream_WithOffset_ReadToEnd_ReturnsOnlyDataInRange()
9069
public async Task PartialStream_WithOffsetAndLength_Seek_WorksCorrectly()
9170
{
9271
// Arrange
93-
#if !NET461 && !NETCOREAPP2_1
94-
await
95-
#endif
96-
using var originalStream = new MemoryStream();
72+
using var originalStream = new MemoryStream();
9773
await originalStream.FillWithRandomBytesAsync(1024);
9874

9975
const int offset = 10;
10076
const int length = 100;
101-
#if !NET461 && !NETCOREAPP2_1
102-
await
103-
#endif
104-
using var partialStream = new PartialStream(originalStream, offset, length);
77+
78+
using var partialStream = new PartialStream(originalStream, offset, length);
10579

10680
// Act
10781
const int additionalOffset = 40;
10882
partialStream.Seek(additionalOffset, SeekOrigin.Begin);
10983

11084
// Assert
111-
#if !NET461 && !NETCOREAPP2_1
112-
await
113-
#endif
114-
using var outputStream = new MemoryStream();
85+
using var outputStream = new MemoryStream();
11586
await partialStream.CopyToAsync(outputStream);
11687

11788
var originalPortion = originalStream
@@ -127,18 +98,13 @@ public async Task PartialStream_WithOffsetAndLength_Seek_WorksCorrectly()
12798
public async Task PartialStream_WithOffsetAndLength_SettingInvalidPosition_Throws()
12899
{
129100
// Arrange
130-
#if !NET461 && !NETCOREAPP2_1
131-
await
132-
#endif
133-
using var originalStream = new MemoryStream();
101+
using var originalStream = new MemoryStream();
134102
await originalStream.FillWithRandomBytesAsync(1024);
135103

136104
const int offset = 10;
137105
const int length = 100;
138-
#if !NET461 && !NETCOREAPP2_1
139-
await
140-
#endif
141-
using var partialStream = new PartialStream(originalStream, offset, length);
106+
107+
using var partialStream = new PartialStream(originalStream, offset, length);
142108

143109
// Act & assert
144110
Assert.Throws<InvalidOperationException>(() => partialStream.Position = 200);
@@ -148,27 +114,19 @@ public async Task PartialStream_WithOffsetAndLength_SettingInvalidPosition_Throw
148114
public async Task PartialStream_WithOffsetAndLength_InnerPositionChanged_StillReadsCorrectly()
149115
{
150116
// Arrange
151-
#if !NET461 && !NETCOREAPP2_1
152-
await
153-
#endif
154-
using var originalStream = new MemoryStream();
117+
using var originalStream = new MemoryStream();
155118
await originalStream.FillWithRandomBytesAsync(1024);
156119

157120
const int offset = 10;
158121
const int length = 100;
159-
#if !NET461 && !NETCOREAPP2_1
160-
await
161-
#endif
162-
using var partialStream = new PartialStream(originalStream, offset, length);
122+
123+
using var partialStream = new PartialStream(originalStream, offset, length);
163124

164125
// Act
165126
originalStream.Position = 1000;
166127

167128
// Assert
168-
#if !NET461 && !NETCOREAPP2_1
169-
await
170-
#endif
171-
using var outputStream = new MemoryStream();
129+
using var outputStream = new MemoryStream();
172130
await partialStream.CopyToAsync(outputStream);
173131

174132
var originalPortion = originalStream.ToArray().Skip(offset).Take(length).ToArray();

test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public async Task Serialization_EnvelopeWithoutItems_Success()
2727
public async Task Deserialization_EnvelopeWithoutItems_Success()
2828
{
2929
// Arrange
30-
#if !NET461 && !NETCOREAPP2_1
31-
await
32-
#endif
33-
using var input = "{\"event_id\":\"12c2d058d58442709aa2eca08bf20986\"}\n".ToMemoryStream();
30+
using var input = "{\"event_id\":\"12c2d058d58442709aa2eca08bf20986\"}\n".ToMemoryStream();
3431

3532
using var expectedEnvelope = new Envelope(
3633
new Dictionary<string, object> { ["event_id"] = "12c2d058d58442709aa2eca08bf20986" },
@@ -72,10 +69,7 @@ public async Task Serialization_EnvelopeWithoutHeader_Success()
7269
public async Task Deserialization_EnvelopeWithoutHeader_Success()
7370
{
7471
// Arrange
75-
#if !NET461 && !NETCOREAPP2_1
76-
await
77-
#endif
78-
using var input = (
72+
using var input = (
7973
"{}\n" +
8074
"{\"type\":\"fake\",\"length\":75}\n" +
8175
"{\"started\": \"2020-02-07T14:16:00Z\",\"attrs\":{\"release\":\"[email protected]\"}}\n"
@@ -149,11 +143,7 @@ public async Task Serialization_EnvelopeWithTwoItems_Success()
149143
[Fact]
150144
public async Task Deserialization_EnvelopeWithTwoItems_Success()
151145
{
152-
// Arrange
153-
#if !NET461 && !NETCOREAPP2_1
154-
await
155-
#endif
156-
using var input = (
146+
using var input = (
157147
"{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42\"}\n" +
158148
"{\"type\":\"attachment\",\"length\":13,\"content_type\":\"text/plain\",\"filename\":\"hello.txt\"}\n" +
159149
"\xef\xbb\xbfHello\r\n\n" +
@@ -242,10 +232,7 @@ public async Task Serialization_EnvelopeWithTwoEmptyItems_Success()
242232
public async Task Deserialization_EnvelopeWithTwoEmptyItems_Success()
243233
{
244234
// Arrange
245-
#if !NET461 && !NETCOREAPP2_1
246-
await
247-
#endif
248-
using var input = (
235+
using var input = (
249236
"{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\"}\n" +
250237
"{\"type\":\"attachment\",\"length\":0}\n" +
251238
"\n" +
@@ -311,10 +298,7 @@ public async Task Serialization_EnvelopeWithItemWithoutLength_Success()
311298
public async Task Deserialization_EnvelopeWithItemWithoutLength_Success()
312299
{
313300
// Arrange
314-
#if !NET461 && !NETCOREAPP2_1
315-
await
316-
#endif
317-
using var input = (
301+
using var input = (
318302
"{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\"}\n" +
319303
"{\"type\":\"attachment\"}\n" +
320304
"helloworld\n"
@@ -372,10 +356,7 @@ public async Task Roundtrip_WithEvent_Success()
372356

373357
using var envelope = Envelope.FromEvent(@event);
374358

375-
#if !NET461 && !NETCOREAPP2_1
376-
await
377-
#endif
378-
using var stream = new MemoryStream();
359+
using var stream = new MemoryStream();
379360

380361
// Act
381362
await envelope.SerializeAsync(stream);
@@ -412,10 +393,7 @@ public async Task Roundtrip_WithEvent_WithAttachment_Success()
412393

413394
using var envelope = Envelope.FromEvent(@event, new[] { attachment });
414395

415-
#if !NET461 && !NETCOREAPP2_1
416-
await
417-
#endif
418-
using var stream = new MemoryStream();
396+
using var stream = new MemoryStream();
419397

420398
// Act
421399
await envelope.SerializeAsync(stream);
@@ -452,10 +430,7 @@ public async Task Roundtrip_WithEvent_WithSession_Success()
452430

453431
using var envelope = Envelope.FromEvent(@event, new[] { attachment }, sessionUpdate);
454432

455-
#if !NET461 && !NETCOREAPP2_1
456-
await
457-
#endif
458-
using var stream = new MemoryStream();
433+
using var stream = new MemoryStream();
459434

460435
// Act
461436
await envelope.SerializeAsync(stream);
@@ -487,10 +462,7 @@ public async Task Roundtrip_WithUserFeedback_Success()
487462

488463
using var envelope = Envelope.FromUserFeedback(feedback);
489464

490-
#if !NET461 && !NETCOREAPP2_1
491-
await
492-
#endif
493-
using var stream = new MemoryStream();
465+
using var stream = new MemoryStream();
494466

495467
// Act
496468
await envelope.SerializeAsync(stream);
@@ -516,10 +488,7 @@ public async Task Roundtrip_WithSession_Success()
516488

517489
using var envelope = Envelope.FromSession(sessionUpdate);
518490

519-
#if !NET461 && !NETCOREAPP2_1
520-
await
521-
#endif
522-
using var stream = new MemoryStream();
491+
using var stream = new MemoryStream();
523492

524493
// Act
525494
await envelope.SerializeAsync(stream);
@@ -541,10 +510,7 @@ public async Task Roundtrip_WithSession_Success()
541510
public async Task Deserialization_EmptyStream_Throws()
542511
{
543512
// Arrange
544-
#if !NET461 && !NETCOREAPP2_1
545-
await
546-
#endif
547-
using var input = new MemoryStream();
513+
using var input = new MemoryStream();
548514

549515
// Act & assert
550516
await Assert.ThrowsAnyAsync<Exception>(
@@ -555,10 +521,7 @@ await Assert.ThrowsAnyAsync<Exception>(
555521
public async Task Deserialization_InvalidData_Throws()
556522
{
557523
// Arrange
558-
#if !NET461 && !NETCOREAPP2_1
559-
await
560-
#endif
561-
using var input = new MemoryStream(new byte[1_000_000]); // all 0's
524+
using var input = new MemoryStream(new byte[1_000_000]); // all 0's
562525

563526
// Act & assert
564527
await Assert.ThrowsAnyAsync<Exception>(
@@ -569,10 +532,7 @@ await Assert.ThrowsAnyAsync<Exception>(
569532
public async Task Deserialization_MalformedData_Throws()
570533
{
571534
// Arrange
572-
#if !NET461 && !NETCOREAPP2_1
573-
await
574-
#endif
575-
using var input = "helloworld\n".ToMemoryStream();
535+
using var input = "helloworld\n".ToMemoryStream();
576536

577537
// Act & assert
578538
await Assert.ThrowsAnyAsync<Exception>(

0 commit comments

Comments
 (0)