コード例 #1
0
        public void PersistState_ThrowsForDuplicateKeys()
        {
            // Arrange
            var currentState     = new Dictionary <string, byte[]>();
            var applicationState = new ComponentApplicationState(currentState, new List <ComponentApplicationState.OnPersistingCallback>());
            var myState          = new byte[] { 1, 2, 3, 4 };

            applicationState.PersistState("MyState", myState);

            // Act & Assert
            Assert.Throws <ArgumentException>(() => applicationState.PersistState("MyState", myState));
        }
コード例 #2
0
        public void PersistState_SavesDataToTheStore()
        {
            // 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.PersistState("MyState", myState);

            // Assert
            Assert.True(currentState.TryGetValue("MyState", out var stored));
            Assert.Equal(myState, stored);
        }