Ejemplo n.º 1
0
        public static void CanSerializeTypeFromMscorlib()
        {
            var data = typeof(string);

            var result = XunitSerializationInfo.Serialize(data);

            Assert.Equal("System.String", result);
        }
Ejemplo n.º 2
0
        public static void CanSerializeTypeFromLocalAssembly()
        {
            var data = typeof(XunitSerializationInfo);

            var result = XunitSerializationInfo.Serialize(data);

            Assert.Equal("Xunit.Serialization.XunitSerializationInfo, test.xunit.execution", result);
        }
Ejemplo n.º 3
0
        public static void CanSerializeEnumFromLocalAssembly()
        {
            var data = MyEnum.SomeValue;

            var result = XunitSerializationInfo.Serialize(data);

            Assert.Equal("SomeValue", result);
        }
Ejemplo n.º 4
0
        public static void CanSerializeEnumFromMscorlib()
        {
            var data = Base64FormattingOptions.InsertLineBreaks;

            var result = XunitSerializationInfo.Serialize(data);

            Assert.Equal("InsertLineBreaks", result);
        }
Ejemplo n.º 5
0
        public static void CanRoundTripIXunitSerializableWithNoSerializedData()
        {
            var data = new MySerializableWithNoData();

            var serialized   = XunitSerializationInfo.Serialize(data);
            var deserialized = (MySerializableWithNoData)XunitSerializationInfo.Deserialize(typeof(MySerializableWithNoData), serialized);

            Assert.NotNull(deserialized);
        }
Ejemplo n.º 6
0
        public static void CanRoundTrip_PublicClass_PublicTestMethod()
        {
            var testCase = TestableTestMethodTestCase.Create <Serialization>("CanRoundTrip_PublicClass_PublicTestMethod");

            var serialized   = XunitSerializationInfo.Serialize(testCase);
            var deserialized = XunitSerializationInfo.Deserialize(typeof(TestableTestMethodTestCase), serialized);

            Assert.NotNull(deserialized);
        }
Ejemplo n.º 7
0
        public static void IXunitSerializableWithoutParameterlessConstructorThrows()
        {
            var data = new MySerializableWithoutParameterlessConstructor(42);

            var serialized = XunitSerializationInfo.Serialize(data);
            var ex         = Record.Exception(() => XunitSerializationInfo.Deserialize(typeof(MySerializableWithoutParameterlessConstructor), serialized));

            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("Could not de-serialize type 'XunitSerializationInfoTests+MySerializableWithoutParameterlessConstructor' because it lacks a parameterless constructor.", ex.Message);
        }
Ejemplo n.º 8
0
        public static void CannotSerializeTypeFromGAC()
        {
            var data = typeof(XmlDocument);

            var ex = Record.Exception(() => XunitSerializationInfo.Serialize(data));

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

            Assert.Equal("type", argEx.ParamName);
            Assert.StartsWith("We cannot serialize type System.Xml.XmlDocument because it lives in the GAC", argEx.Message);
        }
Ejemplo n.º 9
0
        public static void CannotSerializeEnumFromGAC()
        {
            var data = ConformanceLevel.Auto;

            var ex = Record.Exception(() => XunitSerializationInfo.Serialize(data));

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

            Assert.Equal("value", argEx.ParamName);
            Assert.StartsWith("We cannot serialize enum System.Xml.ConformanceLevel.Auto because it lives in the GAC", argEx.Message);
        }
Ejemplo n.º 10
0
        public static void UnsupportedTypeThrows()
        {
            var data = new object();

            var ex = Record.Exception(() => XunitSerializationInfo.Serialize(data));

            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);
        }
Ejemplo n.º 11
0
        public static void CanRoundTypeIXunitSerializable()
        {
            var data = new MySerializable {
                IntValue = 42, StringValue = "Hello\r\nworld!"
            };

            var deserialized = (MySerializable)XunitSerializationInfo.Deserialize(typeof(MySerializable), XunitSerializationInfo.Serialize(data));

            Assert.Equal(42, deserialized.IntValue);
            Assert.Equal("Hello\r\nworld!", deserialized.StringValue);
        }
Ejemplo n.º 12
0
 public static void CanRoundTripIntrinsics(Type dataType, object data)
 {
     Assert.Equal(data, XunitSerializationInfo.Deserialize(dataType, XunitSerializationInfo.Serialize(data)));
 }