Beispiel #1
0
        private void TestAreEqualScalar <T>(T value, T unequalValue)
        {
            // test scalar comparison
            AttributeType scalarTest = new AttributeType("test", typeof(T));

            Assert.True(scalarTest.AreEqual(value, value));
            Assert.True(scalarTest.AreEqual(unequalValue, unequalValue));
            Assert.False(scalarTest.AreEqual(value, unequalValue));
        }
Beispiel #2
0
        private void TestAreEqual <T>(T value, T unequalValue)
        {
            TestAreEqualScalar <T>(value, unequalValue);

            // test array comparison
            AttributeType arrayTest = new AttributeType("test", typeof(T[]), 2);

            Assert.True(arrayTest.AreEqual(new T[] { value, unequalValue }, new T[] { value, unequalValue }));
            Assert.False(arrayTest.AreEqual(new T[] { value }, new T[] { value, unequalValue }));
            Assert.False(arrayTest.AreEqual(new T[] { value, value }, new T[] { value, unequalValue }));
        }
Beispiel #3
0
        // Test that arrays of strings are converted to and from the 'object' type correctly.
        private void TestStringArray(AttributeType stringArrayType)
        {
            // Test without spaces, like in ATF 3.1 when spaces were not handled correctly.
            {
                string[] array =
                {
                    "e1",
                    "e2",
                    "e3",
                    "e4"
                };
                string toString = stringArrayType.Convert(array);
                object toObject = stringArrayType.Convert(toString);
                Assert.IsTrue(stringArrayType.AreEqual(array, toObject));
            }

            // Test elements that have spaces and quotes ('"') and other special characters.
            {
                string[] array =
                {
                    "first",
                    "second with spaces",
                    "third with \\@##\\\\$#%%!\"~~~ possible escape __ characters\n",
                    "\"fourth\""
                };
                string toString = stringArrayType.Convert(array);
                object toObject = stringArrayType.Convert(toString);
                Assert.IsTrue(stringArrayType.AreEqual(array, toObject));
            }

            // Test that empty strings and null strings are encoded correctly.
            {
                string[] array =
                {
                    "first element",
                    "",
                    "\"",
                    ""
                };
                string toString = stringArrayType.Convert(array);
                object toObject = stringArrayType.Convert(toString);
                Assert.IsTrue(stringArrayType.AreEqual(array, toObject));
            }
        }