Compare two variables and continue the test if they are unequal

Experiences, small talk, and other automation gossip.
BlindJones
Posts: 3
Joined: Fri May 17, 2019 7:10 am

Compare two variables and continue the test if they are unequal

Post by BlindJones » Tue Aug 06, 2019 7:47 am

Hello everyone,

i am pretty new to Ranorex and already find the user library code for validation if two captured values are equal.

Now i am trying to figure out how to use it the other way around... I want Ranorex to just continue if the values are unequal.

Can someone help me? I played around with the code and googled something like "validate.arenotequal(value1, value2);" but that did not work.

Here is the code from the "ValidationLibrary" of Ranorex:

Code: Select all

//
// Copyright © 2018 Ranorex All rights reserved
//

using Ranorex.Core.Testing;

namespace Ranorex.AutomationHelpers.UserCodeCollections
{
    /// <summary>
    /// A collection of useful validation helper methods.
    /// </summary>
    [UserCodeCollection]
    public static class ValidationUnequalLibrary
    {
        /// <summary>
        /// Compares two values.
        /// </summary>
        /// <param name="value1">First value to compare</param>
        /// <param name="value2">Second value to compare</param>
        [UserCodeMethod]
        public static void CompareValues(string value1, string value2)
        {
            Validate.AreEqual(value1, value2);
        }
    }
}
So, is there an easy way to modify it to pass the result if the two values are unequal?

Thank you!

Regards
BlindJones

User avatar
Stub
Posts: 274
Joined: Fri Jul 15, 2016 1:35 pm

Re: Compare two variables and continue the test if they are unequal

Post by Stub » Tue Aug 06, 2019 11:44 am

You could use Validate.IsFalse(values are equal) or Validate.IsTrue(values are not equal), or if (values are equal) Validate.Fail(); Several choices are possible here.

BlindJones
Posts: 3
Joined: Fri May 17, 2019 7:10 am

Re: Compare two variables and continue the test if they are unequal

Post by BlindJones » Wed Aug 07, 2019 7:23 am

Thank you very much, Stub! :D

I tried Validate.IsFalse and it worked.