From b3fcae2543075bbb3ac1316c3008ceee1b60dacc Mon Sep 17 00:00:00 2001 From: Sureshkumar T Date: Thu, 1 Jul 2004 05:38:51 +0000 Subject: [PATCH] 2004-07-01 Sureshkumar T * Added test case for OdbcCommand.ExecuteScalar Method * New files: OdbcCommandTest.cs - test suite for OdbcCommand class. svn path=/trunk/mcs/; revision=30601 --- .../Test/System.Data.Odbc/ChangeLog | 5 ++ .../Test/System.Data.Odbc/OdbcCommandTest.cs | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs diff --git a/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog b/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog index bd7b77d4f19..8df7a0151f2 100644 --- a/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog +++ b/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog @@ -1,3 +1,8 @@ +2004-07-01 Sureshkumar T + * Added test case for OdbcCommand.ExecuteScalar Method + * New files: + OdbcCommandTest.cs - test suite for OdbcCommand class. + 2004-06-23 Sureshkumar T * Added test to check whether the OdbcConnection.Close method closes all the handles. diff --git a/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs b/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs new file mode 100644 index 00000000000..8b3968c7062 --- /dev/null +++ b/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs @@ -0,0 +1,70 @@ +// +// OdbcCommandTest.cs - NUnit Test Cases for testing the +// OdbcCommand class +// +// Author: +// Sureshkumar T (TSureshkumar@novell.com) +// +// Copyright (c) 2004 Novell Inc., and the individuals listed +// on the ChangeLog entries. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +using System; +using System.Data; +using System.Data.Odbc; + +using NUnit.Framework; + +namespace MonoTests.System.Data.Odbc +{ + + [TestFixture] + public class OdbcCommandTest : MySqlOdbcBaseClient + { + + [SetUp] + public void GetReady () { + OpenConnection (); + CreateTestSetup (); // create database & test tables + } + + [TearDown] + public void Clean () { + CleanTestSetup (); // clean test database; + CloseConnection (); + } + + /// + /// Test Execute Scalar Method + /// + [Test] + public void ExecuteScalarTest () + { + OdbcCommand cmd = conn.CreateCommand (); + string query = "select count(*) from test order by col_int;"; + cmd.CommandText = query; + object objCount = cmd.ExecuteScalar (); + Assertion.AssertEquals( "ExecuteScalar does not return int type", 5, Convert.ToInt32(objCount)); + } + } +} -- 2.25.1