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

Ask general questions here.
LPG
Posts: 39
Joined: Mon Jul 25, 2011 6:12 pm

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

Post by LPG » Wed Feb 08, 2012 12:54 am

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!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

Post by Support Team » Wed Feb 08, 2012 8:31 am

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