コード例 #1
0
        public void LegacyExceptionsCanBeDeserialized()
        {
            var original = MakeItThrown(new StubException());
            var json     = ExceptionSerializer.LegacyToJson(original);

            var deserialized = Serializer.FromJson <Exception>(json);

            Assert.AreEqual(original.ToString(), deserialized.ToString());
            Assert.AreEqual(original.GetType(), deserialized.GetType());
        }
コード例 #2
0
        public void SerializedExceptionCanBeDotNetSerialized()
        {
            var payload = new JsonObject()
                          .Add("foo", "bar")
                          .Add("baz", 42);

            var original     = new SerializedException(payload);
            var json         = ExceptionSerializer.LegacyToJson(original);
            var deserialized = ExceptionSerializer.LegacyFromJson(json);

            Assert.AreEqual(typeof(SerializedException), deserialized.GetType());
            Assert.AreEqual(
                original.SerializedValue.ToString(),
                ((SerializedException)deserialized).SerializedValue.ToString()
                );
        }