xibinki wrote:So for example, I have these two elements identified on my repository:
Code: Select all
repo.BO.SincronizacaoDeEntidades.Self
repo.BO.SincronizacaoDeProdutos.Self
I also have this validation method:
Code: Select all
public SearchAndValidate (//element I want to pass//) {
bool BValid = true;
while (BValid) {
if (//element I want to pass//Info.Exists()) {
BValid = true;
}
else {
BValid = false;
}
}
}
By using your method:
Code: Select all
Dim myQuery As IEnumerable(Of RepoItemInfo) = From things In repo.SelfInfo.Children
Where things.Name Is Me.myName
Select things
Dim myObject As RepoItemInfo = myQuery.FirstOrDefault()
myObject.WaitForExists(500)
I would only need to call like this:
Not So much
Code: Select all
repo.BO.SincronizacaoDeEntidades.Self)
and
Yes, this is more along the lines of what you'd need to do
Code: Select all
myQuery(repo.BO.SincronizacaoDeProdutos.Self)
And it would search for the item in my repository and tell me if it exists after 500ms while the test is running:
Is that it?
I think you've more or less got the idea.
The query is basically iterating through the collection of repo items and looking for a match on the "name" property. you could do exactly the same thing using a for each loop, although I think it would be more costly from a resource/time prospective.
If I'm perfectly honest, this is the point where I crack open my Ranorex solution in Visual Studio because it has much better real time code analysis and IntelliSense. If you want to throw what you've got up in here, I'll take a look and see if I can get it sorted out.
Give either of these a shot
public RepoItemInfo SearchRepoItemByName(string repoItemName)
{
var myQuery = from things in repo.SelfInfo.Children where ReferenceEquals(things.Name, repoItemName) select things;
return myQuery.FirstOrDefault();
}
to use the above, you'll need to set a variable equal to the function as it's going to return a RepoItemInfo object back to you and then you'd use the waitforExist on it.
RepoItemInfo myObject = SearchRepoItemByName("you string goes here");
myObject.WaitForExists(5000);
__________________________________________________________________________________________
public void SearchByNameAndWaitForExist(string repoItemName, Duration timeOut)
{
var myQuery = from things in repo.SelfInfo.Children where object.ReferenceEquals(things.Name, repoItemName) select things;
myQuery.First().WaitForExists(timeOut);
}
For this one you're not going to get anything back, so you just call the method and provide the arguments.
SearchByNameAndWaitForExist("Your string goes here", 5000);
I didn't actually run either of these conversions, so I can't promise they'll work as expected. Let me know if you run into issues and I can help you through them.