Exemple #1
0
        public async Task GetPersistedStateAsync_RestoresPreexistingStateAsync()
        {
            // Arrange
            var persistedState = "eyJNeVZhbHVlIjoiQVFJREJBPT0ifQ==";
            var store          = new PrerenderComponentApplicationStore(persistedState);
            var expected       = new Dictionary <string, byte[]>()
            {
                ["MyValue"] = new byte[] { 1, 2, 3, 4 }
            };

            // Act
            var state = await store.GetPersistedStateAsync();

            // Assert
            Assert.Equal(expected, state);
        }
    public async Task GetPersistedStateAsync_RestoresPreexistingStateAsync()
    {
        // Arrange
        var persistedState = "eyJNeVZhbHVlIjoiQVFJREJBPT0ifQ==";
        var store          = new PrerenderComponentApplicationStore(persistedState);
        var expected       = new Dictionary <string, ReadOnlySequence <byte> >()
        {
            ["MyValue"] = new ReadOnlySequence <byte>(new byte[] { 1, 2, 3, 4 })
        };

        // Act
        var state = await store.GetPersistedStateAsync();

        // Assert
        Assert.Equal(
            expected.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()),
            state.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray()));
    }