在编码的UI测试中,如何在一个编码的UI测试用例中设置两个表的数据源 [英] In Coded UI test, how can set the two tables data sources in one coded UI test case

查看:71
本文介绍了在编码的UI测试中,如何在一个编码的UI测试用例中设置两个表的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有SQL数据库并创建了两个表.我如何在一个编码的UI测试中使用这两个表.当[DataSource("System.Data.SqlClient"),"Data Source = SQLExpress; Initial Catalog = TestData; Integrated Security = True","UsersData", DataAccessMethod.Sequential),TestMethod].

I have database in SQL and created two tables. How can i use these two tables in one coded UI test. When  [DataSource("System.Data.SqlClient", "Data Source=SQLExpress;Initial Catalog=TestData;Integrated Security=True", "UsersData", DataAccessMethod.Sequential), TestMethod]. 

当我在一个表上使用上面的连接字符串时,它工作正常,但是如果插入第二个表名'contactData'.它不起作用.

When i used above connection string for one table, it work fine but if insert second table name 'contactData'. It does not work. 

[DataSource("System.Data.SqlClient",数据源= SQLExpress;初始目录= TestData;集成安全性= True","UsersData,ContactData",DataAccessMethod.Sequential),TestMethod).

 [DataSource("System.Data.SqlClient", "Data Source=SQLExpress;Initial Catalog=TestData;Integrated Security=True", "UsersData, ContactData", DataAccessMethod.Sequential), TestMethod].

我如何在一个编码的UI测试中添加两个表名?

How i can add two tables name in one coded UI test?

推荐答案

不要在连接字符串中包含该表.您可以张贴一些您用来从表中获取数据的代码吗?

Don't include the table in the Connection String. Can you post some of the code you're using to get data out of the table?

另外,如果您有兴趣,我也有一些有关DataAccess的博客文章.

Also, in case you're interested, I have some blog posts on the subject of DataAccess.

首先,我要说DataAccess永远不应直接包含在UI中.请参阅我的有关多层应用程序的博客文章:

First, let me say that DataAccess should never be included directly in the UI. See my blog post about Multi-tier applications:

http://geek-goddess-bonnie. blogspot.com/2010/10/multi-tier-applications.html

在以上博客文章中,我还具有指向3部分的DataAccess系列的链接,我将继续进行介绍,并在此处包括以下内容:

In the above blog post, I also have links to my 3-part DataAccess series, which I'll go ahead and include here also:

首先,请查看有关数据访问的3部分系列文章,了解一些基本概念:

First, check out my 3-part series on Data Access for some basic ideas:

http://geek-goddess-bonnie. blogspot.com/2009/09/dataaccess-part-i.html
http://geek-goddess-bonnie.blogspot.com /2009/10/dataaccess-part-ii.html
http://geek-goddess-bonnie.blogspot.com /2009/10/dataaccess-part-iii.html

http://geek-goddess-bonnie.blogspot.com/2009/09/dataaccess-part-i.html
http://geek-goddess-bonnie.blogspot.com/2009/10/dataaccess-part-ii.html
http://geek-goddess-bonnie.blogspot.com/2009/10/dataaccess-part-iii.html

每篇文章都为Data Access类增加了额外的复杂性,但具有更大的灵活性.第一篇文章足以使您朝正确的方向前进,并为您提供了有关该概念的一般概念,但是第二篇文章则更有用.第三篇文章比较完整 示例类,但它涉及使用匿名委托,对于初学者来说可能太多了(老实说,我不再使用匿名委托,但几年前我曾在以前的项目中使用过).但是,即使您不想使用 匿名委托方法,更完整的示例类将向您展示如何保存数据,前两篇文章中的示例不这样做.

Each post adds extra complexity to the Data Access classes, but more flexibility. The first post is enough to get you going in the right direction and give you a general idea of the concept, but the second post is more useful. The third post has a more complete example class, but it gets into using anonymous delegates and may be too much for a beginner (which, to be honest, I don't use the anonymous delegates anymore, but I used to on previous projects several years ago). However, even if you don't want to use the anonymous delegate approach, the more complete example class should show you how to save data, which the examples in the first two posts don't do.

这3个帖子很旧,我在2009年写了它们.它们仍然很相关,但是我需要添加两件事:实现IDisposable和使用TransactionScope进行事务.因此,我将此帖子添加到了数据访问"系列中:

Those 3 posts are old, I wrote them back in 2009. They are still relevant, but I needed to add two things: implementing IDisposable and using TransactionScope for transactions. So, I added this post to my Data Access series:

http://geek-goddess- bonnie.blogspot.com/2015/06/dataaccess-revisiting-yet-again.html

我的一些读者对这个代码有一些疑问,已经回覆我,我意识到我仍然缺少一些重要的项目,例如DataAdapter.TableMappings !!所以,我终于写了一篇关于这个的新文章:

Several of my readers have gotten back to me with some questions about this code and I realized that I'm still missing a few important items, such as DataAdapter.TableMappings!! So, I finally wrote a new post about that:

http: //geek-goddess-bonnie.blogspot.com/2016/08/more-dataaccess-and-you-thought-i-was.html

希望这对您有帮助...

Hope this helps ...


这篇关于在编码的UI测试中,如何在一个编码的UI测试用例中设置两个表的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆