/// <summary>Compares a <see cref="Version"/> instance to another and returns an indication of their relative values.</summary>
        /// <param name="version">The version to compare.</param>
        /// <param name="value">The other version to compare.</param>
        /// <param name="comparisonType">Type of the comparison.</param>
        /// <returns>
        /// A signed number indicating the relative values of this instance and value.
        /// <list type="table">
        /// <listheader>
        /// <term>Return Value</term>
        /// <term>Description</term>
        /// </listheader>
        /// <item>
        /// <term>Less than zero</term>
        /// <description>This instance is less than value.</description>
        /// </item>
        /// <item>
        /// <term>Zero</term>
        /// <description>This instance is equal to value.</description>
        /// </item>
        /// <item>
        /// <term>Greater than zero</term>
        /// <description>This instance is greater than value.</description>
        /// </item>
        /// </list>
        /// </returns>
        public static int CompareTo(this Version version, Version value, VersionComparison comparisonType)
        {
            if (value == null)
            {
                return(1);
            }

            if (version.Major != value.Major)
            {
                return(version.Major > value.Major ? 1 : -1);
            }

            if (version.Minor != value.Minor)
            {
                return(version.Minor > value.Minor ? 1 : -1);
            }

            if (version.Build != value.Build && comparisonType == VersionComparison.IgnoreUnset &&
                !(version.Build == -1 || value.Build == -1))
            {
                return(version.Build > value.Build ? 1 : -1);
            }

            if (version.Revision != value.Revision && comparisonType == VersionComparison.IgnoreUnset &&
                !(version.Revision == -1 || value.Revision == -1))
            {
                return(version.Revision > value.Revision ? 1 : -1);
            }

            return(0);
        }
        public static TypeNode GetNewestTypeForClass(int classID)
        {
            List <string> versions = new List <string>();

            foreach (RTTIDatabaseMapping dbm in Mappings)
            {
                if (dbm.ClassID == classID)
                {
                    versions.Add(Versions[dbm.VersionIndex]);
                }
            }
            if (versions.Count < 1)
            {
                throw new ArgumentException("No RTTI instances exist for the given class ID.");
            }
            string newest = VersionComparison.GetNewest(versions.ToArray());

            foreach (RTTIDatabaseMapping dbm in Mappings)
            {
                if (dbm.ClassID == classID && Versions[dbm.VersionIndex] == newest)
                {
                    return(Types[dbm.NodeIndex]);
                }
            }
            throw new ArgumentException("No RTTI instances exist for the given class ID and Unity version.");
        }
        public IEnumerable <Software> GetSoftware(
            string nameFilter    = null,
            string versionFilter = null,
            VersionComparison versionComparision = VersionComparison.EqualTo,
            int maxCount = 100)
        {
            // Validate parameters
            if (maxCount < 1)
            {
                throw new ArgumentException("maxCount must be 1 or greater");
            }

            var allSoftware = GetAllSoftware();

            // No filtering
            if (string.IsNullOrWhiteSpace(nameFilter) && string.IsNullOrWhiteSpace(versionFilter))
            {
                return(allSoftware.Take(maxCount));
            }

            var version = string.IsNullOrWhiteSpace(versionFilter)
                ? null
                : VersionHelper.GetVersion(versionFilter);

            return(allSoftware
                   .Where(o =>
                          CheckName(nameFilter, o.Name) &&
                          CheckVersion(version, o.Version, versionComparision))
                   .Take(maxCount));
        }
 public override int CompareTo(SemanticVersion other, VersionComparison versionComparison)
 {
     if (other is LatestNuGetVersion)
     {
         return(0);
     }
     return(1);
 }
Beispiel #5
0
 public RequireEnterpriseEdition(string versionText = null,
                                 VersionComparison versionCompare = VersionComparison.EqualTo)
     : base(versionText, versionCompare)
 {
     if (string.IsNullOrEmpty(Skip))
     {
         if (!BoltkitHelper.IsEnterprise())
         {
             Skip = "Test requires Neo4j enterprise edition.";
         }
     }
 }
        /// <summary>Determines if two <see cref="Version"/> values are equal.</summary>
        /// <param name="version">The version to compare.</param>
        /// <param name="value">The other version to compare.</param>
        /// <param name="comparisonType">Type of the comparison.</param>
        /// <returns><see langword="true"/> if the values are equal; <see langword="false"/> otherwise.</returns>
        public static bool Equals(this Version version, Version value, VersionComparison comparisonType)
        {
            if (value == null)
            {
                return(false);
            }

            return(version.Major == value.Major && version.Minor == value.Minor &&
                   (version.Build == value.Build || comparisonType != VersionComparison.IgnoreUnset ||
                    version.Build == -1 || value.Build == -1) &&
                   (version.Revision == value.Revision || comparisonType != VersionComparison.IgnoreUnset ||
                    version.Revision == -1 || value.Revision == -1));
        }
Beispiel #7
0
        //Default server version required to run stub tests is anything less than 4.3. After this version testkit takes over the stub tests.
        public RequireBoltStubServerTheoryAttribute(string versionText = "4.3.0",
                                                    VersionComparison versionCompare = VersionComparison.LessThan)
        {
            StringBuilder skipText = new StringBuilder();

            CheckStubServer(skipText);
            RequireServer.RequiredServerAvailable(versionText, versionCompare, skipText);

            if (skipText.Length > 0)
            {
                Skip = skipText.ToString();
            }
        }
Beispiel #8
0
        public RequireServerFactAttribute(string versionText = null,
                                          VersionComparison versionCompare = VersionComparison.EqualTo)
        {
            var skipText = new StringBuilder();

            if (!BoltkitHelper.IsBoltkitAvailable())
            {
                skipText.AppendLine(BoltkitHelper.TestRequireBoltkit);
            }

            if (!string.IsNullOrWhiteSpace(versionText))
            {
                var version          = ServerVersion.From(versionText);
                var availableVersion = ServerVersion.From(BoltkitHelper.ServerVersion());

                var satisfy = false;
                switch (versionCompare)
                {
                case VersionComparison.LessThan:
                    satisfy = availableVersion.CompareTo(version) < 0;
                    break;

                case VersionComparison.LessThanOrEqualTo:
                    satisfy = availableVersion.CompareTo(version) <= 0;
                    break;

                case VersionComparison.EqualTo:
                    satisfy = availableVersion.CompareTo(version) == 0;
                    break;

                case VersionComparison.GreaterThanOrEqualTo:
                    satisfy = availableVersion.CompareTo(version) >= 0;
                    break;

                case VersionComparison.GreaterThan:
                    satisfy = availableVersion.CompareTo(version) > 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(versionCompare));
                }

                if (!satisfy)
                {
                    skipText.AppendLine(
                        $"Test requires available server version {availableVersion} to be {versionCompare.ToString()} {version}.");
                }
            }

            Skip = skipText.ToString();
        }
Beispiel #9
0
 public RequireServerWithIPv6FactAttribute(string versionText = null,
                                           VersionComparison versionCompare = VersionComparison.EqualTo)
     : base(versionText, versionCompare)
 {
     if (string.IsNullOrEmpty(Skip))
     {
         if (!BoltkitHelper.IPV6Available())
         {
             Skip = "IPv6 is not available";
         }
         else if (!BoltkitHelper.IPV6Enabled())
         {
             Skip = "IPv6 is disabled";
         }
     }
 }
Beispiel #10
0
        private void StartComparison_Click(object sender, RoutedEventArgs e)
        {
            VersionComparison vc = new VersionComparison();

            vc.OnMessage += (x) => {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => Messages.Items.Add(x)));
            };

            XbimModel Base     = new XbimModel();
            XbimModel Revision = new XbimModel();

            Base.Open(BaselineTextBox.Text, Xbim.XbimExtensions.XbimDBAccess.Read);
            Revision.Open(RevisedTextBox.Text, Xbim.XbimExtensions.XbimDBAccess.Read);

            Messages.Items.Clear();
            vc.StartComparison(Base, Revision, Filter.Text);
        }
Beispiel #11
0
        public RequireClusterFactAttribute(string versionText = null,
                                           VersionComparison versionCompare = VersionComparison.EqualTo)
        {
            var skipText = new StringBuilder();

            if (!BoltkitHelper.ServerAvailable())
            {
                skipText.AppendLine(BoltkitHelper.TestRequireBoltkit);
            }

            RequireServer.RequiredServerAvailable(versionText, versionCompare, skipText);

            if (skipText.Length > 0)
            {
                Skip = skipText.ToString();
            }
        }
Beispiel #12
0
        public static bool RequiredServerAvailable(string versionText, VersionComparison versionCompare, StringBuilder skipText)
        {
            var satisfy = true;

            if (!string.IsNullOrWhiteSpace(versionText))
            {
                var version          = ServerVersion.From(versionText);
                var availableVersion = ServerVersion.From(BoltkitHelper.ServerVersion());


                switch (versionCompare)
                {
                case VersionComparison.LessThan:
                    satisfy = availableVersion.CompareTo(version) < 0;
                    break;

                case VersionComparison.LessThanOrEqualTo:
                    satisfy = availableVersion.CompareTo(version) <= 0;
                    break;

                case VersionComparison.EqualTo:
                    satisfy = availableVersion.CompareTo(version) == 0;
                    break;

                case VersionComparison.GreaterThanOrEqualTo:
                    satisfy = availableVersion.CompareTo(version) >= 0;
                    break;

                case VersionComparison.GreaterThan:
                    satisfy = availableVersion.CompareTo(version) > 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(versionCompare));
                }

                if (!satisfy)
                {
                    skipText.AppendLine(
                        $"Test requires available server version {availableVersion} to be {versionCompare.ToString()} {version}.");
                }
            }

            return(satisfy);
        }
        private bool CheckVersion(Version versionFilter, Version checkVersion, VersionComparison versionFilterComparision)
        {
            if (versionFilter == null)
            {
                return(true);
            }

            var compareResult = checkVersion.CompareTo(versionFilter);

            return((compareResult == 0 &&
                    (versionFilterComparision == VersionComparison.EqualTo ||
                     versionFilterComparision == VersionComparison.GreaterThanOrEqualTo ||
                     versionFilterComparision == VersionComparison.LessThanOrEqualTo)) ||
                   (compareResult < 0 &&
                    (versionFilterComparision == VersionComparison.LessThan ||
                     versionFilterComparision == VersionComparison.LessThanOrEqualTo)) ||
                   (compareResult > 0 &&
                    (versionFilterComparision == VersionComparison.GreaterThan ||
                     versionFilterComparision == VersionComparison.GreaterThanOrEqualTo)));
        }
Beispiel #14
0
        /// <summary>
        /// Compares the given versions using the VersionComparison mode.
        /// </summary>
        public static int Compare(Version version1, Version version2, VersionComparison versionComparison)
        {
            var comparer = new VersionComparer(versionComparison);

            return(comparer.Compare(version1, version2));
        }
Beispiel #15
0
        /// <summary>
        /// True if the identity objects are equal based on the given comparison mode.
        /// </summary>
        public virtual bool Equals(PackageIdentity other, VersionComparison versionComparison)
        {
            var comparer = new PackageIdentityComparer(versionComparison);

            return(comparer.Equals(this, other));
        }
        /// <summary>
        /// True if the VersionBase objects are equal based on the given comparison mode.
        /// </summary>
        public virtual bool Equals(SemanticVersion other, VersionComparison versionComparison)
        {
            var comparer = new VersionComparer(versionComparison);

            return(comparer.Equals(this, other));
        }
Beispiel #17
0
        /// <summary>
        /// Compares NuGetVersion objects using the given comparison mode.
        /// </summary>
        public int CompareTo(Version other, VersionComparison versionComparison)
        {
            var comparer = new VersionComparer(versionComparison);

            return(comparer.Compare(this, other));
        }
 /// <summary>
 /// Creates a VersionComparer that respects the given comparison mode.
 /// </summary>
 /// <param name="versionComparison">comparison mode</param>
 public VersionComparer(VersionComparison versionComparison)
 {
     _mode = versionComparison;
 }
        /// <summary>
        /// Use a specific VersionComparison for comparison
        /// </summary>
        public bool Equals(VersionRangeBase other, VersionComparison versionComparison)
        {
            IVersionRangeComparer comparer = new VersionRangeComparer(versionComparison);

            return(Equals(other, comparer));
        }
 /// <summary>
 /// Determines if an NuGetVersion meets the requirements using the given mode.
 /// </summary>
 /// <param name="version">SemVer to compare</param>
 /// <param name="versionComparison">VersionComparison mode used to determine the version range.</param>
 /// <returns>True if the given version meets the version requirements.</returns>
 public bool Satisfies(NuGetVersion version, VersionComparison versionComparison)
 {
     return(Satisfies(version, new VersionComparer(versionComparison)));
 }
 /// <summary>
 /// Compare versions with a specific VersionComparison
 /// </summary>
 public PackageIdentityComparer(VersionComparison versionComparison)
     : this(new VersionComparer(versionComparison))
 {
 }
        /// <summary>
        /// Compare versions with a specific VersionComparison
        /// </summary>
        public VersionRangeComparer(VersionComparison versionComparison)
            : this(new VersionComparer(versionComparison))
        {

        }
 /// <summary>
 /// Compare versions with a specific VersionComparison
 /// </summary>
 public PackageIdentityComparer(VersionComparison versionComparison)
     : this(new VersionComparer(versionComparison))
 {
 }
 /// <summary>
 /// Compare versions with a specific VersionComparison
 /// </summary>
 public VersionRangeComparer(VersionComparison versionComparison)
     : this(new VersionComparer(versionComparison))
 {
 }
 /// <summary>
 /// Creates a VersionComparer using the default mode.
 /// </summary>
 public VersionComparer()
 {
     _mode = VersionComparison.Default;
 }
 /// <summary>
 /// Creates a VersionComparer that respects the given comparison mode.
 /// </summary>
 /// <param name="versionComparison">comparison mode</param>
 public VersionComparer(VersionComparison versionComparison)
 {
     _mode = versionComparison;
 }
        /// <summary>
        /// Compares the given versions using the VersionComparison mode.
        /// </summary>
        public static int Compare(SemanticVersion version1, SemanticVersion version2, VersionComparison versionComparison)
        {
            IVersionComparer comparer = new VersionComparer(versionComparison);

            return(comparer.Compare(version1, version2));
        }
Beispiel #28
0
 public VersionComparisonTests()
 {
     versionComparison = new VersionComparison();
 }
Beispiel #29
0
 /// <summary>
 /// Returns a value indicating whether the value of this instance is equal to the value of the specified <see cref="Version"/> instance based on the given comparison mode.
 /// </summary>
 /// <param name="value">The object to compare to this instance.</param>
 /// <param name="versionComparison">One of the enumeration values that specifies how the versions will be compared.</param>
 /// <returns><c>true</c> if the <paramref name="value"/> parameter equals the value of this instance; otherwise, <c>false</c>.</returns>
 public bool Equals(Version value, VersionComparison versionComparison)
 {
     return(CompareTo(value, versionComparison) == 0);
 }
Beispiel #30
0
        /// <summary>
        /// Compares NuGetVersion objects using the given comparison mode.
        /// </summary>
        public virtual int CompareTo(SimpleVersion other, VersionComparison versionComparison)
        {
            VersionComparer comparer = new VersionComparer(versionComparison);

            return(comparer.Compare(this, other));
        }
        /// <summary>
        /// Compares NuGetVersion objects using the given comparison mode.
        /// </summary>
        public virtual int CompareTo(SemanticVersion other, VersionComparison versionComparison)
        {
            var comparer = new VersionComparer(versionComparison);

            return(comparer.Compare(this, other));
        }
Beispiel #32
0
 /// <summary>
 /// True if the VersionBase objects are equal based on the given comparison mode.
 /// </summary>
 public virtual bool Equals(SemanticVersion other, VersionComparison versionComparison)
 {
     return(CompareTo(other, versionComparison) == 0);
 }
 /// <summary>
 /// Creates a VersionComparer using the default mode.
 /// </summary>
 public VersionComparer()
 {
     _mode = VersionComparison.Default;
 }
Beispiel #34
0
 /// <summary>
 /// Determines if an NuGetVersion meets the requirements using the given mode.
 /// </summary>
 /// <param name="version">SemVer to compare</param>
 /// <param name="versionComparison">VersionComparison mode used to determine the version range.</param>
 /// <returns>True if the given version meets the version requirements.</returns>
 public bool Satisfies(SimpleVersion version, VersionComparison versionComparison)
 {
     return Satisfies(version, new VersionComparer(versionComparison));
 }
 /// <summary>
 /// Compares the given versions using the VersionComparison mode.
 /// </summary>
 public static int Compare(StrictSemanticVersion version1, StrictSemanticVersion version2, VersionComparison versionComparison)
 {
     IVersionComparer comparer = new VersionComparer(versionComparison);
     return comparer.Compare(version1, version2);
 }
Beispiel #36
0
 /// <summary>
 /// Compares the given versions using the VersionComparison mode.
 /// </summary>
 public static int Compare(SimpleVersion version1, SimpleVersion version2, VersionComparison versionComparison)
 {
     IVersionComparer comparer = new VersionComparer(versionComparison);
     return comparer.Compare(version1, version2);
 }