1 // DbCommandBuilderTest.cs - NUnit Test Cases for DbCommandBuilder class
4 // Gert Driesen (drieseng@users.sourceforge.net)
6 // Copyright (C) 2008 Gert Driesen
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Data.Common;
32 using System.Globalization;
34 using NUnit.Framework;
36 namespace MonoTests.System.Data.Common
39 public class DbCommandBuilderTest
42 public void QuotePrefix ()
44 MyCommandBuilder cb = new MyCommandBuilder ();
45 Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
46 cb.QuotePrefix = "mono";
47 Assert.AreEqual ("mono", cb.QuotePrefix, "#2");
48 cb.QuotePrefix = null;
49 Assert.AreEqual (string.Empty, cb.QuotePrefix, "#3");
50 cb.QuotePrefix = "'\"";
51 Assert.AreEqual ("'\"", cb.QuotePrefix, "#4");
52 cb.QuotePrefix = string.Empty;
53 Assert.AreEqual (string.Empty, cb.QuotePrefix, "#5");
55 Assert.AreEqual (" ", cb.QuotePrefix, "#6");
59 public void QuoteSuffix ()
61 MyCommandBuilder cb = new MyCommandBuilder ();
62 Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
63 cb.QuoteSuffix = "mono";
64 Assert.AreEqual ("mono", cb.QuoteSuffix, "#2");
65 cb.QuoteSuffix = null;
66 Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#3");
67 cb.QuoteSuffix = "'\"";
68 Assert.AreEqual ("'\"", cb.QuoteSuffix, "#4");
69 cb.QuoteSuffix = string.Empty;
70 Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#5");
73 private class MyCommandBuilder : DbCommandBuilder
75 protected override string GetParameterPlaceholder (int parameterOrdinal)
77 return string.Format (CultureInfo.InvariantCulture,
78 "@PH:{0}@", parameterOrdinal);
81 protected override string GetParameterName (string parameterName)
83 return string.Format (CultureInfo.InvariantCulture,
84 "@NAME:{0}@", parameterName);
87 protected override string GetParameterName (int parameterOrdinal)
89 return string.Format (CultureInfo.InvariantCulture,
90 "@NAME:{0}@", parameterOrdinal);
93 protected override void ApplyParameterInfo (DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
97 protected override void SetRowUpdatingHandler (DbDataAdapter adapter)