Page 1 of 1

Validate.NotExist timeout help

Posted: Mon Jan 31, 2011 6:13 pm
by Gunner1980
So I have the following method I am using to try to validate that a certain repo item is not present but I am having mixed results. Sometimes the method works fine an other times it ignores my timeout of 10s and performs the NotExist immediately (less than 10 ms after the previous action) which fails my test.

Code: Select all

 public static void Validate_DropTrack()
        {
            
            Report.Info("Validating Track # " + TrackNum + " was dropped");
    
            bool result = Validate.NotExists(repo.FormTacViewC2.PictureTrackInfo.AbsolutePath, 10000, Validate.DefaultMessage, false);
            
                if (result == true)
                {
                    Report.Success("Successfully dropped track # " + TrackNum);
                }
                else
                {
                    Report.Screenshot();
                    Report.Debug("Track # " + TrackNum + " failed to drop within 10 seconds, proceeding to next track creation.");
                }
            
        }
        
I have also tried the following code with the same results.

Code: Select all

public static void Validate_DropTrack()
        {
            Duration OrigDur = repo.FormTacViewC2.PictureTrackInfo.SearchTimeout;
            repo.FormTacViewC2.PictureTrackInfo.SearchTimeout = 10000;

            Report.Info("Validating Track # " + TrackNum + " was dropped");
    
            bool result = Validate.NotExists(repo.FormTacViewC2.PictureTrackInfo, Validate.DefaultMessage, false);
            
                if (result == true)
                {
                    Report.Success("Successfully dropped track # " + TrackNum);
                }
                else
                {
                    Report.Debug("Track # " + TrackNum + " failed to drop within 10 seconds, proceeding to next track creation.");
                    Report.Screenshot();                
                }
            
            repo.FormTacViewC2.PictureTrackInfo.SearchTimeout = OrigDur;
        }
Am I doing something incorrect? Is there another way I could be performing this check?

Re: Validate.NotExist timeout help

Posted: Mon Jan 31, 2011 9:52 pm
by ekrell
Correct me if I'm wrong, but it looks like you're trying to check "after ten seconds does this item still exist". The method you're using thinks more like "Does this item exist now and after ten seconds stop checking"

If you want the first option I think you have to hard code in a delay or something to make it wait and then tell it to look for the item. I may have completely misunderstood your description of what's happening though.

Edward

Re: Validate.NotExist timeout help

Posted: Mon Jan 31, 2011 10:07 pm
by Gunner1980
Ah ok thanks I guess I will add a 10 second delay before this validation. I really would like something that would look for the item and then fail if it still exists after 10 seconds. It should disappear fairly quickly but in some cases it can take a few seconds which is why I can't really use tryfindsingle method either unless I hard code a delay. Is there anything that works like this that I can use?

Re: Validate.NotExist timeout help

Posted: Mon Jan 31, 2011 10:56 pm
by ekrell
The only way to set that up that I know of is to use a while loop with two conditions.
Something like:

Code: Select all

System.DateTime start_time = System.DateTime.Now;
bool result = true;
while ( result && System.DateTime.Now.Subtract( start_time ).Seconds < 10 )
{
        result = repo.folder.TryFindSingle(RxPath, out randomElement);
}
Where the path is for the item you're trying to find.

After the loop is exited check the status of result, if it's true the item still exists and you can do the failure report if it's false the item has disappeared and your test has passed.

Edward

Re: Validate.NotExist timeout help

Posted: Mon Jan 31, 2011 11:28 pm
by Gunner1980
Thanks for the help!