Mercurial > pub > bltoolkit
diff UnitTests/CS/DataAccess/ScalarListTest.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UnitTests/CS/DataAccess/ScalarListTest.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,160 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using NUnit.Framework; + +using BLToolkit.Data; +using BLToolkit.DataAccess; + +namespace DataAccess +{ + [TestFixture] + public class ScalarListTest + { + public abstract class TestAccessor : DataAccessor + { + [SprocName("Person_SelectAll")] + [ObjectType(typeof(int))] + public abstract ArrayList SelectIDs (DbManager db); + + [SprocName("Person_SelectAll")] + [ObjectType(typeof(string)), ScalarFieldName(1)] + public abstract ArrayList SelectFirstNames(DbManager db); + + [SprocName("Person_SelectAll")] + [ObjectType(typeof(string)), ScalarFieldName("LastName")] + public abstract ArrayList SelectLastNames (DbManager db); + + [SprocName("Person_SelectAll")] + public abstract List<int> GenericsSelectIDs (DbManager db); + + [SprocName("Person_SelectAll")] + [ScalarFieldName(1)] + public abstract List<string> GenericsSelectFirstNames (DbManager db); + + [SprocName("Person_SelectAll")] + [ScalarFieldName("LastName")] + public abstract List<string> GenericsSelectLastNames (DbManager db); + + [SprocName("Person_SelectAll"), ObjectType(typeof(int))] + public abstract List<IConvertible> GenericsSelectIDsAsIConvertible(DbManager db); + + [SprocName("Person_SelectAll")] + public abstract void GenericsSelectIDsReturnVoid (DbManager db, [Destination] List<int> list); + + public static TestAccessor CreateInstance() + { + return (TestAccessor)CreateInstance(typeof(TestAccessor)); + } + } + + [Test] + public void SelectIDsTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + ArrayList list = ta.SelectIDs(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + Assert.IsTrue(list[0] is int); + } + } + + [Test] + public void SelectFirstNamesTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + ArrayList list = ta.SelectFirstNames(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + Assert.IsTrue(list[0] is string); + } + } + + [Test] + public void SelectLastNamesTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + ArrayList list = ta.SelectLastNames(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + Assert.IsTrue(list[0] is string); + } + } + + [Test] + public void GenericsSelectIDsTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + List<int> list = ta.GenericsSelectIDs(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + } + } + + [Test] + public void GenericsSelectIDsAsIConvertibleTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + List<IConvertible> list = ta.GenericsSelectIDsAsIConvertible(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + } + } + + [Test] + public void GenericsSelectIDsReturnVoidTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + List<int> list = new List<int>(); + ta.GenericsSelectIDsReturnVoid(db, list); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + } + } + + [Test] + public void GenericsSelectFirstNamesTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + List<string> list = ta.GenericsSelectFirstNames(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + } + } + + [Test] + public void GenericsSelectLastNamesTest() + { + using (DbManager db = new DbManager()) + { + TestAccessor ta = TestAccessor.CreateInstance(); + List<string> list = ta.GenericsSelectLastNames(db); + + Assert.IsNotNull (list); + Assert.IsNotEmpty(list); + } + } + } +}