Skip to content

Commit 2dcd66b

Browse files
eerhardtjaviercn
authored andcommitted
Flip around where AsSpan is called with string comparisons in tests.
1 parent c62b82d commit 2dcd66b

17 files changed

+156
-156
lines changed

src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests/Cng/GcmAuthenticatedEncryptorTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ public void Encrypt_KnownKey()
100100
// | 00 00 00 00 (postBuffer)
101101

102102
string retValAsString = Convert.ToBase64String(retVal);
103-
Assert.Equal("AAAAAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaG0O2kY0NZtmh2UQtXY5B2jlgnOgAAAAA".AsSpan(), retValAsString);
103+
Assert.Equal("AAAAAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaG0O2kY0NZtmh2UQtXY5B2jlgnOgAAAAA", retValAsString);
104104
}
105105
}

src/DataProtection/DataProtection/test/Microsoft.AspNetCore.DataProtection.Tests/KeyManagement/KeyRingBasedDataProtectorTests.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public void Protect_EncryptsToDefaultProtector_MultiplePurposes()
4545
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
4646
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
4747
{
48-
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
49-
Assert.Equal(expectedAad.AsSpan(), actualAad);
48+
Assert.Equal(expectedPlaintext, actualPlaintext.AsSpan());
49+
Assert.Equal(expectedAad, actualAad.AsSpan());
5050
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
5151
});
5252

@@ -83,8 +83,8 @@ public void Protect_EncryptsToDefaultProtector_SinglePurpose()
8383
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
8484
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
8585
{
86-
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
87-
Assert.Equal(expectedAad.AsSpan(), actualAad);
86+
Assert.Equal(expectedPlaintext, actualPlaintext.AsSpan());
87+
Assert.Equal(expectedAad, actualAad.AsSpan());
8888
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
8989
});
9090

@@ -423,8 +423,8 @@ public void Unprotect_KeyRevoked_RevocationAllowed_ReturnsOriginalData_SetsRevok
423423
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
424424
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
425425
{
426-
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
427-
Assert.Equal(expectedAad.AsSpan(), actualAad);
426+
Assert.Equal(expectedCiphertext, actualCiphertext.AsSpan());
427+
Assert.Equal(expectedAad, actualAad.AsSpan());
428428
return expectedPlaintext;
429429
});
430430
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
@@ -470,8 +470,8 @@ public void Unprotect_IsAlsoDefaultKey_Success_NoMigrationRequired()
470470
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
471471
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
472472
{
473-
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
474-
Assert.Equal(expectedAad.AsSpan(), actualAad);
473+
Assert.Equal(expectedCiphertext, actualCiphertext.AsSpan());
474+
Assert.Equal(expectedAad, actualAad.AsSpan());
475475
return expectedPlaintext;
476476
});
477477
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
@@ -519,8 +519,8 @@ public void Unprotect_IsNotDefaultKey_Success_RequiresMigration()
519519
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
520520
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
521521
{
522-
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
523-
Assert.Equal(expectedAad.AsSpan(), actualAad);
522+
Assert.Equal(expectedCiphertext, actualCiphertext.AsSpan());
523+
Assert.Equal(expectedAad, actualAad.AsSpan());
524524
return expectedPlaintext;
525525
});
526526
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
@@ -594,8 +594,8 @@ public void CreateProtector_ChainsPurposes()
594594
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
595595
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
596596
{
597-
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
598-
Assert.Equal(expectedAad.AsSpan(), actualAad);
597+
Assert.Equal(expectedPlaintext, actualPlaintext.AsSpan());
598+
Assert.Equal(expectedAad, actualAad.AsSpan());
599599
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
600600
});
601601

src/Http/Headers/test/CacheControlHeaderValueTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public void Properties_SetAndGetAllProperties_SetValueReturnedInGetter()
4747
Assert.Throws<FormatException>(() => cacheControl.NoCacheHeaders.Add("invalid PLACEHOLDER"));
4848
cacheControl.NoCacheHeaders.Add("PLACEHOLDER");
4949
Assert.Single(cacheControl.NoCacheHeaders);
50-
Assert.Equal("PLACEHOLDER".AsSpan(), cacheControl.NoCacheHeaders.First());
50+
Assert.Equal("PLACEHOLDER", cacheControl.NoCacheHeaders.First().AsSpan());
5151

5252
Assert.NotNull(cacheControl.PrivateHeaders);
5353
Assert.Throws<ArgumentException>(() => cacheControl.PrivateHeaders.Add(null));
5454
Assert.Throws<FormatException>(() => cacheControl.PrivateHeaders.Add("invalid PLACEHOLDER"));
5555
cacheControl.PrivateHeaders.Add("PLACEHOLDER");
5656
Assert.Single(cacheControl.PrivateHeaders);
57-
Assert.Equal("PLACEHOLDER".AsSpan(), cacheControl.PrivateHeaders.First());
57+
Assert.Equal("PLACEHOLDER", cacheControl.PrivateHeaders.First().AsSpan());
5858

5959
// NameValueHeaderValue collection property
6060
Assert.NotNull(cacheControl.Extensions);

0 commit comments

Comments
 (0)