Page 1 of 1

Using of "Validate" for strings instead of Ranorex objects?

Posted: Wed Feb 08, 2012 12:54 am
by LPG
Can I somehow use "Validate" to validate the contents of a string, and NOT of a Ranorex object? I need to verify that each line of an XML document has the expected text.

So basically, I end up with 2 strings:
------------------------------------------
string expectedString = "US";
string fromXML = xmlDoc.SelectSingleNode("blabla", nameSpaceMgr).InnerText;

Now I simply need to verify that the 2 strings match.
-------------------------------------------------------------
Validate.??????(expectedString, fromXML); //How do I validate that they match?

Of course I can do If/Else, or using C#'s string.Compare, but this is not ideal, because:
* I have to verify a long document, so it would be more maintainable to have one-liner code for each validation.
* I also need the Ranorex script to fail if it does NOT match, so a Validate of some sort would make that easy to reduce lines of code for each check too.


Thanks!

Re: Using of "Validate" for strings instead of Ranorex objects?

Posted: Wed Feb 08, 2012 8:31 am
by Support Team
Hi,

to validate if two string are equal you can use following method:
AreEqual(Object, Object)

You code should look something like this:
string expectedString = "US";
string fromXML = xmlDoc.SelectSingleNode("blabla", nameSpaceMgr).InnerText;
Validate.AreEqual(expectedString, fromXML);
Regards,
Tobias
Ranorex Support Team