index > Visual Studio Team System - Testers > Reading from a csv file

Reading from a csv file

I learned how to add a data file to my script by searching around this knowledge base. However, I am having trouble reading from it. My issue is probably more a lack of c# programming language than anything so thanks for any newb coding help in advance.

The following DataSource is defined in my project...

[DataSource("creditCards", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Temp;Persist Security Info=False;" +
"Extended Properties=text", Microsoft.VisualStudio.TestTools.WebTesting.DataBindingAccessMethod.Random, "cc#csv")]

the csv file looks like this...
cc_number,cc_month,cc_year
444444444444444,01,08

I am trying to access the data like this...
request5Body.FormPostParameters.Add("PrimaryCreditCard:_CardNumber", this.Context.creditCards["cc_number"].ToString());

Am I on the right track?
jadamo

The easiest way to see the correct syntax is to create a web test and add the datasource using the editor. Then do the databinding in the editor and then generate a coded class.

But you are close. You would access the data with something like,

request5Body.FormPostParameters.Add("PrimaryCreditCard:_CardNumber", this.Context["creditCards.cc#csv.cc_number"].ToString());

You should also have an attribute at the top that is something like:

[DataBinding("creditCards", "cc#csv", "cc_number", "creditCards.cc#csv.cc_number")]




Blog - http://blogs.msdn.com/slumley/default.aspx
slumley MSFT
Hey, thanks a lot for the help. I thought I might be making it to hard. I just saw how you can do this in the editor. This is a pretty slick tool.
jadamo
reply 3

You can use google to search for other answers

 

More Articles

• Load tests not getting dependent files
• Manual Test Case Migration PS to VSTS
• .NET Unit test Microsoft.VisualStudio.QualityTools.Common cannot ...
• How to use TDD for User Interface in Web apps
• Names of accessor classes
• How analyze the results using graph
• Forum Programming Language Suggestion
• Required Attribute Value test fails! Bug?
• Throughput calculation
• How to use Team System Testing tools?
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Incorrect code coverage results
• Unable to Debug Unit Test
• How do I derive from TestContext class a
• Extraction/validation Rule Code
• Errors (503, Remote server)
• Using MSTest.exe with WebDev.WebServer a
• publish permissions full control for sha
• Repeating a section
• Question about binding and executing onc
• ASP.Net Unit Tests Failing
• Flex web application currently running i
• Where are response HTML stored for WebTe
• Using Team System Tester Tools with VS 2
• WebTestContext
• Error 302 in Web tests

Hot Articles

• How to revoke the "Administer Test
• Web Tests & Client Certs
• Help me please with WebTest
• Specifying custom properties for Unit Te
• Internal Error! Failed to acquire a Read
• Synchronized users in a loadtest
• IOExceptions
• I cannot create unit test for my applica
• Tests not appearing in test manager lists
• Problem with Tests after renaming project
• Context parameters across multiple web t
• Has anyone used Generic test with a 3rd
• All tests failing with "Can't save
• query installing VSTS
• Databinding issue

Recommend Articles

• Rig
• Access to Private Variables
• Automated Test?
• How to create parameters in custom extra
• Grouping and filtering manual tests
• Sample Website, Database and WebTests
• What If Your Expected Result Is a Runtim
• WebDav supports in Web Test
• which database and tables store the test
• Test Run deployment issue: The location
• run unit tests on different databases
• Displying results thorugh Reporting Serv
• Load Testing Windows Application
• Work item changes
• web test fails after adding extraction r