public static void CanRoundTripIntrinsics(Type dataType, object data)
        {
            var triple       = new XunitSerializationTriple(Guid.NewGuid().ToString(), data, dataType);
            var serialized   = XunitSerializationInfo.SerializeTriple(triple);
            var deserialized = XunitSerializationInfo.DeserializeTriple(serialized);

            Assert.Equal(triple.Key, deserialized.Key);
            Assert.Equal(triple.Type, deserialized.Type);
            Assert.Equal(triple.Value, deserialized.Value);
        }
        public static void UnsupportedTypeThrows()
        {
            var triple = new XunitSerializationTriple(Guid.NewGuid().ToString(), new object(), typeof(object));

            var ex = Record.Exception(() => XunitSerializationInfo.SerializeTriple(triple));

            var argEx = Assert.IsType <ArgumentException>(ex);

            Assert.Equal("value", argEx.ParamName);
            Assert.StartsWith("We don't know how to serialize type System.Object", argEx.Message);
        }
        public static void CanRoundTypeIXunitSerializable()
        {
            var data = new MySerializable {
                IntValue = 42, StringValue = "Hello\r\nworld!"
            };
            var triple       = new XunitSerializationTriple(Guid.NewGuid().ToString(), data, data.GetType());
            var serialized   = XunitSerializationInfo.SerializeTriple(triple);
            var deserialized = XunitSerializationInfo.DeserializeTriple(serialized);

            Assert.Equal(triple.Key, deserialized.Key);
            Assert.Equal(triple.Type, deserialized.Type);
            var deserializedInner = (MySerializable)deserialized.Value;

            Assert.Equal(42, deserializedInner.IntValue);
            Assert.Equal("Hello\r\nworld!", deserializedInner.StringValue);
        }
Example #4
0
        public string SerializeToString()
        {
            var triple = new XunitSerializationTriple(nameof(VsTestCaseBase), this, GetType());

            return(XunitSerializationInfo.SerializeTriple(triple));
        }