IDbCommandTest.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // IDbCommandTest.cs - NUnit Test Cases for testing the
  2. // IDbCommand implemented classes.
  3. //
  4. // Authors:
  5. // Sureshkumar T ([email protected])
  6. //
  7. // Copyright (c) 2004 Novell Inc., and the individuals listed on the
  8. // ChangeLog entries.
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person
  12. // obtaining a copy of this software and associated documentation
  13. // files (the "Software"), to deal in the Software without
  14. // restriction, including without limitation the rights to use, copy,
  15. // modify, merge, publish, distribute, sublicense, and/or sell copies
  16. // of the Software, and to permit persons to whom the Software is
  17. // furnished to do so, subject to the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  26. // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29. // SOFTWARE.using System;
  30. using System.Data;
  31. using System.Data.Common;
  32. using Mono.Data;
  33. using NUnit.Framework;
  34. namespace MonoTests.System.Data
  35. {
  36. [TestFixture]
  37. [Category ("odbc"), Category ("sqlserver")]
  38. public class CommandTest
  39. {
  40. [Test]
  41. public void ExecuteScalarTest ()
  42. {
  43. IDbConnection conn = ConnectionManager.Singleton.Connection;
  44. try {
  45. ConnectionManager.Singleton.OpenConnection ();
  46. IDbCommand cmd = conn.CreateCommand ();
  47. cmd.CommandType = CommandType.Text;
  48. cmd.CommandText = "select count(*) from employee where id < 3";
  49. Assert.AreEqual (2, cmd.ExecuteScalar (), "#1 there should be 2 records");
  50. } finally {
  51. ConnectionManager.Singleton.CloseConnection ();
  52. }
  53. }
  54. }
  55. }