⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employeedaoservice_parametermaptest.cs

📁 利用iBatis架构开发Web应用程序的初学实例。
💻 CS
字号:
// The following code was generated by Microsoft Visual Studio 2005.
// The test owner should check each test for validity.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Collections.Generic;
using DaoProvider;
using System.Collections;
namespace Test
{
    /// <summary>
    ///This is a test class for DaoProvider.EmployeeDaoService and is intended
    ///to contain all DaoProvider.EmployeeDaoService Unit Tests
    ///</summary>
    [TestClass()]
    public class EmployeeDaoService_ParameterMapTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for InsertWithParameterClass (Employee)
        ///</summary>
        [TestMethod()]
        public void InsertWithParameterClassTest()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();
            p_dataObject.LastName = Guid.NewGuid().ToString().Substring(0, 10);
            p_dataObject.FirstName = Guid.NewGuid().ToString().Substring(0, 10);

            int expected = 0;

            expected = target.InsertWithParameterClass(p_dataObject);

            Assert.AreNotEqual<int>(0, expected);
            Employee m_retDataObject = target.QueryWithParameterClassForObject(p_dataObject);
            Assert.IsNotNull(m_retDataObject);
            Assert.AreEqual<string>(m_retDataObject.LastName, p_dataObject.LastName);
            Assert.AreEqual<string>(m_retDataObject.FirstName, p_dataObject.FirstName);
        }

        /// <summary>
        ///A test for InsertWithParameterMap1 (Employee)
        ///</summary>
        [TestMethod()]
        public void InsertWithParameterMap1Test()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();
            p_dataObject.LastName = Guid.NewGuid().ToString().Substring(0, 10);
            p_dataObject.FirstName = Guid.NewGuid().ToString().Substring(0, 10);

            int expected = 0;

            expected = target.InsertWithParameterMap1(p_dataObject);

            Assert.AreNotEqual<int>(0, expected);
            Employee m_retDataObject = target.QueryWithParameterClassForObject(p_dataObject);
            Assert.IsNotNull(m_retDataObject);
            Assert.AreEqual<string>(m_retDataObject.LastName, p_dataObject.LastName);
            Assert.AreEqual<string>(m_retDataObject.FirstName, p_dataObject.FirstName);
        }

        /// <summary>
        ///A test for InsertWithParameterMap2 (Employee)
        ///</summary>
        [TestMethod()]
        public void InsertWithParameterMap2Test()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();
            p_dataObject.LastName = Guid.NewGuid().ToString().Substring(0, 10);
            p_dataObject.FirstName = Guid.NewGuid().ToString().Substring(0, 10);

            int expected = 0;

            expected = target.InsertWithParameterMap2(p_dataObject);

            Assert.AreNotEqual<int>(0, expected);
            Employee m_retDataObject = target.QueryWithParameterClassForObject(p_dataObject);
            Assert.IsNotNull(m_retDataObject);
            Assert.AreEqual<string>(m_retDataObject.LastName, p_dataObject.LastName);
            Assert.AreEqual<string>(m_retDataObject.FirstName, p_dataObject.FirstName);
        }

        /// <summary>
        ///A test for InsertWithParameterMap3 (Employee)
        ///</summary>
        [TestMethod()]
        public void InsertWithParameterMap3Test()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();
            p_dataObject.LastName = Guid.NewGuid().ToString().Substring(0, 10);
            p_dataObject.FirstName = Guid.NewGuid().ToString().Substring(0, 10);

            int expected = 0;

            expected = target.InsertWithParameterMap3(p_dataObject);

            Assert.AreNotEqual<int>(0, expected);
            Employee m_retDataObject = target.QueryWithParameterClassForObject(p_dataObject);
            Assert.IsNotNull(m_retDataObject);
            //注意比较的属性名顺序
            Assert.AreEqual<string>(m_retDataObject.FirstName, p_dataObject.LastName);
            Assert.AreEqual<string>(m_retDataObject.LastName, p_dataObject.FirstName);
        }

        /// <summary>
        ///A test for InsertWithProcdure (Employee)
        ///</summary>
        [TestMethod()]
        public void InsertWithProcdureTest()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();
            p_dataObject.LastName = Guid.NewGuid().ToString().Substring(0, 10);
            p_dataObject.FirstName = Guid.NewGuid().ToString().Substring(0, 10);

            int expected = 0;

            expected = target.InsertWithProcdure(p_dataObject);

            Assert.AreNotEqual<int>(0, expected);
            p_dataObject.EmployeeID = expected;
            Employee m_retDataObject = target.QueryWithParameterClassForObject(p_dataObject);
            Assert.IsNotNull(m_retDataObject);
            //注意比较的属性名顺序
            Assert.AreEqual<string>(m_retDataObject.FirstName, p_dataObject.LastName);
            Assert.AreEqual<string>(m_retDataObject.LastName, p_dataObject.FirstName);
        }

        /// <summary>
        ///A test for QueryWithParameterClass (Employee)
        ///</summary>
        [TestMethod()]
        public void QueryWithParameterClassTest()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();

            p_dataObject.EmployeeID = 1;
            p_dataObject.LastName = "Fuller";

            IList actual;

            actual = target.QueryWithParameterClass(p_dataObject);
            //假设数据库中有这两条数据
            Assert.AreEqual<int>(2, actual.Count);

        }

        /// <summary>
        ///A test for QueryWithParameterMap1 (Employee)
        ///</summary>
        [TestMethod()]
        public void QueryWithParameterMap1Test()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();

            p_dataObject.EmployeeID = 1;
            p_dataObject.LastName = "Fuller";

            IList actual;

            actual = target.QueryWithParameterMap1(p_dataObject);

            //假设数据库中有这两条数据
            Assert.AreEqual<int>(2, actual.Count);
        }

        /// <summary>
        ///A test for QueryWithParameterMap2 (Employee)
        ///</summary>
        [TestMethod()]
        public void QueryWithParameterMap2Test()
        {
            EmployeeDaoService target = new EmployeeDaoService();

            Employee p_dataObject = new Employee();

            p_dataObject.EmployeeID = 1;
            p_dataObject.LastName = "Fuller";

            IList actual;

            actual = target.QueryWithParameterMap2(p_dataObject);

            //假设数据库中有这两条数据
            Assert.AreEqual<int>(2, actual.Count);
        }

    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -