public void PersistAsJson_NullValue() { // Arrange var currentState = new Dictionary <string, byte[]>(); var applicationState = new ComponentApplicationState(currentState, new List <ComponentApplicationState.OnPersistingCallback>()); // Act applicationState.PersistAsJson <byte []>("MyState", null); // Assert Assert.True(currentState.TryGetValue("MyState", out var stored)); Assert.Null(JsonSerializer.Deserialize <byte[]>(stored)); }
public void PersistAsJson_SerializesTheDataToJson() { // Arrange var currentState = new Dictionary <string, byte[]>(); var applicationState = new ComponentApplicationState(currentState, new List <ComponentApplicationState.OnPersistingCallback>()); var myState = new byte[] { 1, 2, 3, 4 }; // Act applicationState.PersistAsJson("MyState", myState); // Assert Assert.True(currentState.TryGetValue("MyState", out var stored)); Assert.Equal(myState, JsonSerializer.Deserialize <byte[]>(stored)); }