public void NullSafeSetTest3()
 {
     UriUserType target = new UriUserType();
     Uri subject = new Uri("http://my.domain.com/dit is ee" + UriUserType.UriLikeWildcard + "n test % met _/een underscore/../bla./bla?");
     string original = subject.AbsoluteUri;
     IDbCommand cmd = new SqlCommand(@"SELECT * FROM TUUT WHERE a = @a");
     SqlParameter param = new SqlParameter(@"a", null);
     cmd.Parameters.Add(param);
     target.NullSafeSet(cmd, subject, 0);
     string expected = original.Replace(@"%", @"[%]");
     expected = expected.Replace(@"_", @"[_]");
     expected = expected.Replace(@"?", @"[?]");
     expected = expected.Replace(UriUserType.UriLikeWildcard, @"%");
     Assert.AreEqual(expected, param.Value.ToString());
     Console.WriteLine("Search predicate DB: " + param.Value);
 }
 public void NullSafeSetTest()
 {
     UriUserType target = new UriUserType();
     IDbCommand cmd = new SqlCommand(@"SELECT * FROM TUUT WHERE a = @a");
     SqlParameter param = new SqlParameter(@"a", null);
     cmd.Parameters.Add(param);
     foreach (Uri uri in s_Subjects)
     {
         target.NullSafeSet(cmd, uri, 0);
         if (uri != null)
         {
             Assert.AreEqual(param.Value.ToString(), uri.AbsoluteUri);
         }
         else
         {
             Assert.IsTrue(param.Value is DBNull);
         }
         Console.WriteLine("To DB: " + param.Value);
     }
 }
 public void NullSafeSetTest2()
 {
     UriUserType target = new UriUserType();
     IDbCommand cmd = new SqlCommand(@"SELECT * FROM TUUT WHERE a = @a");
     SqlParameter param = new SqlParameter(@"a", null);
     cmd.Parameters.Add(param);
     foreach (Uri uri in s_Subjects)
     {
         if (uri != null)
         {
             string original = uri.AbsoluteUri;
             Uri subject = new Uri(uri.AbsoluteUri + UriUserType.UriLikeWildcard);
             target.NullSafeSet(cmd, subject, 0);
             string expected = original.Replace(@"%", @"[%]");
             expected = expected.Replace(@"_", @"[_]");
             expected = expected.Replace(@"?", @"[?]");
             Assert.IsTrue(param.Value.ToString().StartsWith(expected));
             Assert.IsTrue(param.Value.ToString().EndsWith(@"%"));
             Console.WriteLine("Search predicate DB: " + param.Value);
         }
     }
 }
 public void RoundtripTest()
 {
     // writer
     UriUserType target = new UriUserType();
     IDbCommand cmd = new SqlCommand(@"SELECT * FROM TUUT WHERE a = @a");
     SqlParameter param = new SqlParameter(@"a", null);
     cmd.Parameters.Add(param);
     // reader
     DataReaderMock rs = new DataReaderMock();
     string[] names = { @"a" };
     object owner = new object();
     // test
     foreach (Uri subject in s_Subjects)
     {
         target.NullSafeSet(cmd, subject, 0);
         string dbField = param.Value is DBNull ? null : param.Value.ToString();
         rs.VarChar = dbField;
         object reading = target.NullSafeGet(rs, names, owner);
         Assert.AreEqual(subject, reading);
         target.NullSafeSet(cmd, subject, 0);
         string dbField2 = param.Value is DBNull ? null : param.Value.ToString();
         Assert.AreEqual(dbField, dbField2);
     }
 }