I have a Coded UI test on a simple calculator application in data driven mode. After adding an assertion, I am not getting my test result passed which I think is due to "." (the decimal point which is already present in Windows calculator application).
Hence I just want to know how to write code so that all type of values including decimal and integers are accepted. My CSV file used for the data-table is
input1 input2 expected_add
1.2 2.3 3.5
2.4 2.5 4.9
5.6 1.4 7
Here the first and second rows are passing but third one is failing.
Here is the sample code that I used for data driven testing.
this.UIMap.add_2_dec_numParams.UICalculatorDialogSendKeys = TestContext.DataRow["input1"].ToString();
this.UIMap.add_2_dec_numParams.UIItemEditSendKeys = "{add}" + TestContext.DataRow["input2"].ToString() + "=";
this.UIMap.add_2_dec_num();
this.UIMap.add_asertExpectedValues.UIItemEditText = TestContext.DataRow["expected_add"].ToString()+" ";
this.UIMap.add_asert();
The first two rows are getting passed because they have decimals. In the expected result of third row I need to make the value 7
as 7.
only then it will be accepted by calculator. That is the problem..
If I change the code to the following:
this.UIMap.add_asertExpectedValues.UIItemEditText = TestContext.DataRow["expected_add"].ToString()+"."+" ";
Then the third row will pass and the first two rows will fail. And error will show as expected <3.5 > actual<3.5. >
and expected <4.9 > actual<4.9. >
that is the problem.