Page 1 of 1

What is the correct use of DataRange.MaxRange?

Posted: Wed Feb 15, 2012 2:08 am
by carsonw
Hi there, this piece of code isn't quite behaving the way I expect:

Code: Select all

if (TestCase.Current.DataContext.CurrentRowIndex == TestCase.Current.DataRange.MaxRange)
TestCase.Current.DataContext.CurrentRowIndex is returning the correct row (1 through 6), but MaxRange (aand MinRange) both always return -1.

I'm guessing I'm using this wrong, but I'm not sure the correct way to use it. Thanks in advance! :)

Re: What is the correct use of DataRange.MaxRange?

Posted: Wed Feb 15, 2012 8:46 am
by Support Team
Hi,

if you are setting a Data Range within your Data Source, MaxRange and MinRange are representing the limits of this Data Range.

To get the number of rows returned, you can use following code snippet:
DataSources.Get("<yourConnector>").Rows.Count
whereas <yourConnector> is the name of your Data Connector.


Regards,
Tobias
Ranorex Support Team

Re: What is the correct use of DataRange.MaxRange?

Posted: Wed Feb 15, 2012 6:08 pm
by carsonw
Thanks very much! I was hoping to get the binding associated with the current test, rather than having to call it by name (in case the name changes for some reason then I don't have to update the code). I'm not sure if that can be done - if not this works great.

Re: What is the correct use of DataRange.MaxRange?

Posted: Thu Feb 16, 2012 12:14 pm
by Support Team
Hi,
carsonw wrote:Thanks very much! I was hoping to get the binding associated with the current test, rather than having to call it by name (in case the name changes for some reason then I don't have to update the code). I'm not sure if that can be done - if not this works great.
If you want to use the current DataConnector for a TestCase, you could use the following line of code instead of the name of the dataconnector.
string dataConnectorName = TestCase.Current.DataContext.Source.Connector.Name;
Regards,
Peter
Ranorex Team

Re: What is the correct use of DataRange.MaxRange?

Posted: Thu Feb 16, 2012 7:48 pm
by carsonw
Perfect, thanks kindly!