Exemplo n.º 1
0
        public void TestStringFormat()
        {
            string v;

            v = SqlFormat.StringFormatLike("Coucou  ", withTrim: false);
            AssertAreEqual(v, "'Coucou  '", "Chaine Like1");

            v = SqlFormat.StringFormatLike("Coucou  ", withTrim: false, avant: true);
            AssertAreEqual(v, "'%Coucou  '", "Chaine Like2");

            v = SqlFormat.StringFormatLike("Coucou  ", withTrim: false, apres: true);
            AssertAreEqual(v, "'Coucou  %'", "Chaine Like3");

            v = SqlFormat.StringFormatLike("Coucou  ", withTrim: false, avant: true, apres: true);
            AssertAreEqual(v, "'%Coucou  %'", "Chaine Like4");

            v = SqlFormat.StringFormatLike("Coucou  ", avant: false, apres: true, withTrim: true);
            AssertAreEqual(v, "'Coucou%'", "Chaine Like5");

            v = SqlFormat.StringFormatLike("Coucou  ", withTrim: true, unicode: true);
            AssertAreEqual(v, "N'Coucou'", "Chaine Like6");

            v = SqlFormat.StringFormat("Coucou les petits  ", maxLength: 6);
            AssertAreEqual(v, "'Coucou'", "Chaine 7");

            v = SqlFormat.StringFormat(" ", nullable: true);
            AssertAreEqual(v, "NULL", "Chaine 8.1");

            v = SqlFormat.StringFormat(" ", nullable: false);
            AssertAreEqual(v, "''", "Chaine 8.2");

            v = SqlFormat.StringFormat(string.Empty, nullable: true);
            AssertAreEqual(v, "NULL", "Chaine 9");

            v = SqlFormat.StringFormat(null, nullable: true);
            AssertAreEqual(v, "NULL", "Chaine 10");

            v = SqlFormat.StringFormat(null, 255, nullable: true);
            AssertAreEqual(v, "NULL", "Chaine 10");

            v = SqlFormat.StringFormat("Rock n'roll", unicode: true);
            AssertAreEqual(v, "N'Rock n''roll'", "Chaine 11");
        }