Skip to content

Commit d5bb40d

Browse files
committed
Fix tests
1 parent d8b5f8c commit d5bb40d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Mvc/Mvc.TagHelpers/test/PrerenderComponentApplicationStoreTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Buffers;
66
using System.Collections.Generic;
7+
using System.Linq;
78
using System.Threading.Tasks;
89
using Microsoft.AspNetCore.Components;
910
using Xunit;
@@ -45,7 +46,9 @@ public async Task GetPersistedStateAsync_RestoresPreexistingStateAsync()
4546
var state = await store.GetPersistedStateAsync();
4647

4748
// Assert
48-
Assert.Equal(expected, state);
49+
Assert.Equal(
50+
expected.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()),
51+
state.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()));
4952
}
5053
}
5154
}

src/Mvc/Mvc.TagHelpers/test/ProtectedPrerenderComponentApplicationStateTest.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Buffers;
66
using System.Collections.Generic;
7+
using System.Linq;
78
using System.Security.Cryptography;
89
using System.Text.Json;
910
using System.Threading.Tasks;
@@ -41,9 +42,9 @@ public async Task PersistStateAsync_ProtectsPersistedState()
4142
public async Task GetPersistStateAsync_CanUnprotectPersistedState()
4243
{
4344
// Arrange
44-
var expectedState = new Dictionary<string, ReadOnlySequence<byte>>()
45+
var expectedState = new Dictionary<string, byte []>()
4546
{
46-
["MyValue"] = new ReadOnlySequence<byte>(new byte[] { 1, 2, 3, 4 })
47+
["MyValue"] = new byte[] { 1, 2, 3, 4 }
4748
};
4849

4950
var persistedState = Convert.ToBase64String(_protector.Protect(JsonSerializer.SerializeToUtf8Bytes(expectedState)));
@@ -53,7 +54,9 @@ public async Task GetPersistStateAsync_CanUnprotectPersistedState()
5354
var restored = await store.GetPersistedStateAsync();
5455

5556
// Assert
56-
Assert.Equal(expectedState, restored);
57+
Assert.Equal(
58+
expectedState.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()),
59+
restored.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()));
5760
}
5861

5962
[Fact]

0 commit comments

Comments
 (0)