public void Serialize_Exception_PreservesValues()
        {
            // Arrange
            ArgumentException exception;

            try
            {
                ThrowArgumentNullException();
                throw new InvalidOperationException();
            }
            catch (ArgumentNullException ex)
            {
                exception = ex;
            }
            var exceptionObject = SerializedException.FromException(exception);
            var stateSerializer = new StateSerializer();

            stateSerializer.Serialize("Foo", exceptionObject);
            stateSerializer.Dispose();
            var stateDeserializer = new StateDeserializer(stateSerializer.GetState());

            // Act
            var result = stateDeserializer.Deserialize <SerializedException>("Foo");

            // Assert
            Assert.Equal(exception.Message, result.Message);
            Assert.Equal(exception.StackTrace, result.StackTrace);
            Assert.Equal(typeof(ArgumentNullException), result.ExceptionType);
            Assert.Equal(exception.ParamName, result.AdditionalProperties["ParamName"]);
        }
        public void Serialize_Value_Ok(object value)
        {
            // Arrange
            var stateSerializer = new StateSerializer();

            stateSerializer.Serialize("foo", value);
            stateSerializer.Dispose();
            var stateDeserializer = new StateDeserializer(stateSerializer.GetState());

            // Act
            var result = stateDeserializer.Deserialize("foo", value.GetType());

            // Assert
            Assert.Equal(value, result);
        }
        public void Serialize_Object_PreservesData()
        {
            // Arrange
            var stateSerializer  = new StateSerializer();
            var serializedObject = new SerializedObject(new CustomData("Foo"));

            stateSerializer.Serialize("Foo", serializedObject);
            stateSerializer.Dispose();
            var stateDeserializer = new StateDeserializer(stateSerializer.GetState());

            // Act
            var result = stateDeserializer.Deserialize <SerializedObject>("Foo");

            // Assert
            Assert.Equal("Foo", result.Values["Value"]);
        }