<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andy's Blog</title><link>http://blogs.msdn.com/andyphilpotts/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Easily bind to CSV or XML data sources </title><link>http://blogs.msdn.com/andyphilpotts/archive/2007/06/20/easily-bind-to-csv-or-xml-data-sources.aspx</link><pubDate>Wed, 20 Jun 2007 21:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3429320</guid><dc:creator>aphilpot</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/andyphilpotts/comments/3429320.aspx</comments><wfw:commentRss>http://blogs.msdn.com/andyphilpotts/commentrss.aspx?PostID=3429320</wfw:commentRss><description>
&lt;p&gt;We have some new features in the upcoming release of Visual Studio Team System (Orcas). I'm going to talk about a commonly&amp;nbsp;requested feature to make binding of tests to simple sources like CSV and XML easy to do&amp;nbsp;(other team members will be blogging about other enhancements). &lt;/p&gt;

&lt;p&gt;In Visual Studio 2005 binding to a simple source like a file with comma-separated values (CSV) required a deep understanding of how OLEDB over JET handled such files. Sean, one of my co-workers, blogged about this &lt;a href="http://blogs.msdn.com/slumley/pages/adding-different-types-of-data-sources-to-a-web-test.aspx" class="" title="data binding in 2005" target="_blank" mce_href="http://blogs.msdn.com/slumley/pages/adding-different-types-of-data-sources-to-a-web-test.aspx"&gt;somewhat unintuitive process&lt;/a&gt;. XML was even trickier and required the use of a custom data source, Sean explained this too, in &lt;a href="http://blogs.msdn.com/slumley/pages/custom-data-binding-in-web-tests.aspx" title="custom data binding" target="_blank" mce_href="http://blogs.msdn.com/slumley/pages/custom-data-binding-in-web-tests.aspx"&gt;this article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With Orcas the process is much easier, and with minor differences can be applied to Web Tests, Coded Web Tests or Unit Tests. Lets take a look at adding a CSV based data source to a Web Test.&lt;/p&gt;

&lt;p&gt;Create a new web test and in the web test editor, right click and select "Add Data Source...". The new Data Source Wizard will appear:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/andyphilpotts/images/3551155/original.aspx" mce_src="http://blogs.msdn.com/photos/andyphilpotts/images/3551155/original.aspx"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;The first page of the wizard allows you to select CSV, XML or Database. Pick CSV and browse for the file you want to use. To help select the file a preview of the file content is shown. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/andyphilpotts/images/3551157/original.aspx" mce_src="http://blogs.msdn.com/photos/andyphilpotts/images/3551157/original.aspx"&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;When you are happy with the file you have selected, click on finish. At this point you have achieved in a handful of steps what would have been very difficult before.&lt;/p&gt;
&lt;p&gt;When a file based data source is used you will be presented with the option to copy the file into your project. &lt;/p&gt;

&lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/andyphilpotts/images/3551151/original.aspx" mce_src="http://blogs.msdn.com/photos/andyphilpotts/images/3551151/original.aspx"&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;This is recommended since the test project will then be self contained, complete with a data source file which will be automatically deployed, there is no need to manually specify the file as a deployment item. There is an added benefit which is that when working in a team environment other users can just grab the project and go.&lt;/p&gt;

&lt;p&gt;For an XML file the process is almost identical, except since XML files support multiple tables in a single file there is the added step of selecting one or more tables. One issue with XML files is knowing the correct format. Since all data sources are expected to be tabular, not just any XML file will do. In a future posting I plan to go into more detail on this, including how to create appropriate data files from code, but to get you going here is an example using the simplest format.&lt;/p&gt;
&lt;p&gt;Here we define two tables, &lt;span style="font-weight: bold;"&gt;Users&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;Products&lt;/span&gt;. Users has the columns UserName and Role, Products has the columns ProductName and Quantity.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version="1.0" standalone="yes"?&amp;gt;&lt;br&gt;&amp;lt;SampleData&amp;gt;&lt;br&gt; &amp;lt;Users&amp;gt;&lt;br&gt;  &amp;lt;UserName&amp;gt;Tony&amp;lt;/UserName&amp;gt;&lt;br&gt;  &amp;lt;Role&amp;gt;Guest&amp;lt;/Role&amp;gt;&lt;br&gt; &amp;lt;/Users&amp;gt;&lt;br&gt; &amp;lt;Users&amp;gt;&lt;br&gt;  &amp;lt;UserName&amp;gt;Andy&amp;lt;/UserName&amp;gt;&lt;br&gt;  &amp;lt;Role&amp;gt;Admin&amp;lt;/Role&amp;gt;&lt;br&gt; &amp;lt;/Users&amp;gt;&lt;br&gt; &amp;lt;Users&amp;gt;&lt;br&gt;  &amp;lt;UserName&amp;gt;Sarah&amp;lt;/UserName&amp;gt;&lt;br&gt;  &amp;lt;Role&amp;gt;User&amp;lt;/Role&amp;gt;&lt;br&gt; &amp;lt;/Users&amp;gt;&lt;br&gt; &amp;lt;Users&amp;gt;&lt;br&gt;  &amp;lt;UserName&amp;gt;Ben&amp;lt;/UserName&amp;gt;&lt;br&gt;  &amp;lt;Role&amp;gt;User&amp;lt;/Role&amp;gt;&lt;br&gt; &amp;lt;/Users&amp;gt;&lt;br&gt; &amp;lt;Products&amp;gt;&lt;br&gt;  &amp;lt;ProductName&amp;gt;SuperMixer 3000&amp;lt;/ProductName&amp;gt;&lt;br&gt;  &amp;lt;Quantity&amp;gt;16&amp;lt;/Quantity&amp;gt;&lt;br&gt; &amp;lt;/Products&amp;gt;&lt;br&gt; &amp;lt;Products&amp;gt;&lt;br&gt;  &amp;lt;ProductName&amp;gt;Bath Magic&amp;lt;/ProductName&amp;gt;&lt;br&gt;  &amp;lt;Quantity&amp;gt;5&amp;lt;/Quantity&amp;gt;&lt;br&gt; &amp;lt;/Products&amp;gt;&lt;br&gt; &amp;lt;Products&amp;gt;&lt;br&gt;  &amp;lt;ProductName&amp;gt;Rainbow Selection&amp;lt;/ProductName&amp;gt;&lt;br&gt;  &amp;lt;Quantity&amp;gt;45&amp;lt;/Quantity&amp;gt;&lt;br&gt; &amp;lt;/Products&amp;gt;&lt;br&gt;&amp;lt;/SampleData&amp;gt;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case you want to plunge in and investigate other supported formats, just know that we use the built in capability of a DataSet to load from XML, as described in detail here: &lt;a href="http://msdn2.microsoft.com/en-us/library/84sxtbxh%28VS.71%29.aspx" title="XML and the DataSet" target="_blank" mce_href="http://msdn2.microsoft.com/en-us/library/84sxtbxh(VS.71).aspx"&gt;XML and the DataSet.&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3429320" width="1" height="1"&gt;</description></item><item><title>Please allow me to introduce myself...</title><link>http://blogs.msdn.com/andyphilpotts/archive/2007/06/20/please-allow-me-to-introduce-myself.aspx</link><pubDate>Wed, 20 Jun 2007 21:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3428948</guid><dc:creator>aphilpot</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/andyphilpotts/comments/3428948.aspx</comments><wfw:commentRss>http://blogs.msdn.com/andyphilpotts/commentrss.aspx?PostID=3428948</wfw:commentRss><description>&lt;P&gt;My name is Andy Philpotts and have been a software developer for the last 30 years. Currently I work here at&amp;nbsp;Microsoft as&amp;nbsp;a Software Design Engineer&amp;nbsp;on the Visual Studio Team System&amp;nbsp;Test Tools. I have worked on the web test and load test features, as well as helping out where I can in the area unit tests and test infrastructure.&lt;/P&gt;
&lt;P&gt;My blog postings will mostly be about topics relating to the products I am working on.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3428948" width="1" height="1"&gt;</description></item></channel></rss>