当前位置: 首页>>代码示例>>C#>>正文


C# SqlServer.FetchDataSet方法代码示例

本文整理汇总了C#中SqlServer.FetchDataSet方法的典型用法代码示例。如果您正苦于以下问题:C# SqlServer.FetchDataSet方法的具体用法?C# SqlServer.FetchDataSet怎么用?C# SqlServer.FetchDataSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlServer的用法示例。


在下文中一共展示了SqlServer.FetchDataSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlServer_FetchDataSet_CommandIsNull_ThrowsArgumentNullException

// ReSharper disable InconsistentNaming
        public void SqlServer_FetchDataSet_CommandIsNull_ThrowsArgumentNullException()
// ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var sqlServer = new SqlServer();
            try
            {
                //------------Execute Test---------------------------
                sqlServer.FetchDataSet((SqlCommand)null);

                //------------Assert Results-------------------------
            }
            finally
            {
                sqlServer.Dispose();
            }
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:18,代码来源:SqlServerTests.cs

示例2: SqlServer_FetchDataSet_ConnectionNotInitialized_ThrowsConnectFirstException

// ReSharper disable InconsistentNaming
        public void SqlServer_FetchDataSet_ConnectionNotInitialized_ThrowsConnectFirstException()
// ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var sqlServer = new SqlServer();
            try
            {
                //------------Execute Test---------------------------
                sqlServer.FetchDataSet();

                //------------Assert Results-------------------------
            }
            finally
            {
                sqlServer.Dispose();
            }
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:18,代码来源:SqlServerTests.cs

示例3: SqlServer_FetchDataSet_CallsNestedFactory_ParamsOnly_UsesNestedCommand

        // ReSharper disable InconsistentNaming
        public void SqlServer_FetchDataSet_CallsNestedFactory_ParamsOnly_UsesNestedCommand()
        // ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var factory = new Mock<IDbFactory>();
            var mockCommand = new Mock<IDbCommand>();
            mockCommand.Setup(a => a.ExecuteReader(It.IsAny<CommandBehavior>())).Returns(new Mock<IDataReader>().Object);
            mockCommand.Setup(a => a.CommandText).Returns("Dave.Bob");
            var added = new SqlCommand().Parameters;
            mockCommand.Setup(a => a.Parameters).Returns(added);
            var helpTextCommand = new Mock<IDbCommand>();
            helpTextCommand.Setup(a => a.ExecuteReader(It.IsAny<CommandBehavior>())).Returns(new Mock<IDataReader>().Object);
            DataTable dt = new DataTable();
            dt.Columns.Add("database_name");
            dt.Rows.Add(new object[] { "Bob" });
            dt.Rows.Add(new object[] { "Dave" });
            factory.Setup(a => a.GetSchema(It.IsAny<IDbConnection>(), "Databases")).Returns(dt);
            var conn = new Mock<IDbConnection>();
            conn.Setup(a => a.State).Returns(ConnectionState.Open);
            conn.Setup(a => a.ConnectionString).Returns("bob");
            conn.Setup(a => a.CreateCommand()).Returns(mockCommand.Object);
            factory.Setup(a => a.CreateConnection(It.IsAny<string>())).Returns(conn.Object);
            factory.Setup(a => a.FetchDataSet(It.IsAny<DbCommand>())).Returns(new DataSet());
            var sqlServer = new SqlServer(factory.Object);
            try
            {

                PrivateObject pvt = new PrivateObject(sqlServer);
                pvt.SetField("_connection", conn.Object);
                pvt.SetField("_command", mockCommand.Object);
                //------------Execute Test---------------------------
                sqlServer.FetchDataSet( new SqlParameter[] { });
                factory.Verify(a => a.FetchDataSet(It.IsAny<IDbCommand>()));
            }
            finally
            {
                sqlServer.Dispose();
            }
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:40,代码来源:SqlServerTests.cs

示例4: SqlServer_FetchDataSet_CorrectDataReturned

        public void SqlServer_FetchDataSet_CorrectDataReturned()
        {
            //------------Setup for test--------------------------
            var dbSource = SqlServerTestUtils.CreateDev2TestingDbSource();

            var sqlServer = new SqlServer();
            try
            {
                sqlServer.Connect(dbSource.ConnectionString, CommandType.StoredProcedure, "Pr_CitiesGetCountries");

                //------------Execute Test---------------------------
                var actualDataSet = sqlServer.FetchDataSet(new SqlParameter("@Prefix", "a"));

                //------------Assert Results-------------------------
                Assert.AreEqual(1, actualDataSet.Tables.Count);

                var actual = actualDataSet.Tables[0];

                SqlServerTestUtils.Verify_DataTable_CountriesPrefixIsA(actual);
            }
            finally
            {
                sqlServer.Dispose();
            }
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:25,代码来源:SqlServerTests.cs


注:本文中的SqlServer.FetchDataSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。