public void TryRetrieveFromJson_NullValue()
        {
            // Arrange
            var serialized    = JsonSerializer.SerializeToUtf8Bytes <byte []>(null);
            var existingState = new Dictionary <string, byte[]>()
            {
                ["MyState"] = serialized
            };
            var applicationState = new ComponentApplicationState(new Dictionary <string, byte[]>(), new List <ComponentApplicationState.OnPersistingCallback>());

            applicationState.InitializeExistingState(existingState);

            // Act
            Assert.True(applicationState.TryRedeemFromJson <byte[]>("MyState", out var stored));

            // Assert
            Assert.Null(stored);
            Assert.False(applicationState.TryRedeemFromJson <byte[]>("MyState", out _));
        }
        public void TryRetrieveFromJson_DeserializesTheDataFromJson()
        {
            // Arrange
            var myState       = new byte[] { 1, 2, 3, 4 };
            var serialized    = JsonSerializer.SerializeToUtf8Bytes(myState);
            var existingState = new Dictionary <string, byte[]>()
            {
                ["MyState"] = serialized
            };
            var applicationState = new ComponentApplicationState(new Dictionary <string, byte[]>(), new List <ComponentApplicationState.OnPersistingCallback>());

            applicationState.InitializeExistingState(existingState);

            // Act
            Assert.True(applicationState.TryRedeemFromJson <byte []>("MyState", out var stored));

            // Assert
            Assert.Equal(myState, stored);
            Assert.False(applicationState.TryRedeemFromJson <byte[]>("MyState", out _));
        }