Exemple #1
0
        public void TestSerializationIncludesProperty(PropertyInfo propertyInfo, object value1, object value2)
        {
            var conf = new UnsafeSandboxConfiguration();

            propertyInfo.SetValue(conf, value1);
            var serializedBytes1 = SerializeToByteArray(conf);

            XAssert.AreEqual(value1, propertyInfo.GetValue(DeserializeFromByteArray(serializedBytes1)));

            propertyInfo.SetValue(conf, value2);
            var serializedBytes2 = SerializeToByteArray(conf);

            XAssert.AreEqual(value2, propertyInfo.GetValue(DeserializeFromByteArray(serializedBytes2)));

            // checking that serialized byte arrays are not equal ensures that the property was accounted for during serialization
            XAssert.ArrayNotEqual(serializedBytes1, serializedBytes2);
        }
Exemple #2
0
        public void TestArrayEqualSimple()
        {
            var len0Arr = new string[0];
            var len1Arr = new[] { "str1" };
            var len2Arr = new[] { "str1", "str2" };

            XAssert.ArrayEqual <object>(null, null);

            XAssert.ArrayNotEqual(len1Arr, null);
            XAssert.ArrayNotEqual(null, len1Arr);

            XAssert.ArrayEqual(len0Arr, len0Arr);
            XAssert.ArrayEqual(len1Arr, len1Arr);

            XAssert.ArrayNotEqual(len0Arr, len1Arr);
            XAssert.ArrayNotEqual(len1Arr, len0Arr);
            XAssert.ArrayNotEqual(new[] { "another string" }, len1Arr);
            XAssert.ArrayNotEqual(len2Arr, len1Arr);

            XAssert.ArrayNotEqual(new[] { new ObjectWithBogusToString(1) }, null);
            XAssert.ArrayNotEqual(new[] { new ObjectWithBogusToString(1) }, new[] { new ObjectWithBogusToString(2) });
            XAssert.ArrayEqual(new[] { new ObjectWithBogusToString(1) }, new[] { new ObjectWithBogusToString(1) });
        }