I have a csv file. All I have to do is to read the csv file and display an assert if the condition is met.
My values are - TLevel,0.2; Mtr, 1; Rmt, TRUE; K, 0
I have to read this csv file and create an assert if " Rmt is False,TLevel is > 0.5 and Mtr =1 " then make the test pass. Otherwise it should make the test fail. Any help is appreciated. I'm new to coded UI and haven't used C#.
I have already created data binding to read the csv file.
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
public void displayTTL()
{
string a = TestContext.DataRow["value"].ToString();
string Controls = TestContext.DataRow["Con"].ToString();
System.Console.WriteLine("The value of "
+this.TestContext.DataRow["Con"]
+ " is " + a);
Assert.AreEqual(1, this.TestContext.DataRow["value"]);
This only displays the last line from my csv file in the test output. I would like to assert every single line of my csv file. Every single row has a different assert condition. My csv file has
Con,Value MTL1,1 TTL1.L, 0.5
[DataSource...]attribute, that is for data driven tests. You do not "display an assert", you assert that a condition holds. If it does not hold then the test fails. The rest of your question is not at all clear. What values are you testing, where are they located, what have you tried so far. I think you need to learn about data driven testing, or possibly about C# and Coded UI in general. - AdrianHHH