Exemple #1
0
        public bool Compare(string firstElement, string secondElement, OperationEnumeration operation)
        {
            var firstEvrString = new EvrString(firstElement);
            var secondEvrString = new EvrString(secondElement);

            var evrIsEqual = ProcessEvrComparisionForEquals(firstEvrString, secondEvrString);
            var evrIsGreaterThan = ProcessEvrComparisionFor(firstEvrString, secondEvrString, ComparisionResults.IsGreaterThan);
            var evrIsLessThan = ProcessEvrComparisionFor(firstEvrString, secondEvrString, ComparisionResults.IsLessThan);

            switch (operation)
            {
                case OperationEnumeration.equals:
                    return evrIsEqual;
                case OperationEnumeration.notequal:
                    return !evrIsEqual;
                case OperationEnumeration.greaterthan:
                    return evrIsGreaterThan;
                case OperationEnumeration.lessthan:
                    return evrIsLessThan;
                case OperationEnumeration.greaterthanorequal:
                    return evrIsGreaterThan || evrIsEqual;
                case OperationEnumeration.lessthanorequal:
                    return evrIsLessThan || evrIsEqual;
                default:
                    throw new InvalidOvalOperationException();
            }
        }
Exemple #2
0
        public bool Compare(string firstElement, string secondElement, OperationEnumeration operation)
        {
            var firstEvrString  = new EvrString(firstElement);
            var secondEvrString = new EvrString(secondElement);

            var evrIsEqual       = ProcessEvrComparisionForEquals(firstEvrString, secondEvrString);
            var evrIsGreaterThan = ProcessEvrComparisionFor(firstEvrString, secondEvrString, ComparisionResults.IsGreaterThan);
            var evrIsLessThan    = ProcessEvrComparisionFor(firstEvrString, secondEvrString, ComparisionResults.IsLessThan);

            switch (operation)
            {
            case OperationEnumeration.equals:
                return(evrIsEqual);

            case OperationEnumeration.notequal:
                return(!evrIsEqual);

            case OperationEnumeration.greaterthan:
                return(evrIsGreaterThan);

            case OperationEnumeration.lessthan:
                return(evrIsLessThan);

            case OperationEnumeration.greaterthanorequal:
                return(evrIsGreaterThan || evrIsEqual);

            case OperationEnumeration.lessthanorequal:
                return(evrIsLessThan || evrIsEqual);

            default:
                throw new InvalidOvalOperationException();
            }
        }
Exemple #3
0
        private bool ProcessEvrComparisionFor(EvrString firstEvr, EvrString secondEvr, ComparisionResults expectedResult)
        {
            var epochComparisionResult = compareEpoches(firstEvr.Epoch, secondEvr.Epoch);

            if (epochComparisionResult.Equals(expectedResult))
            {
                return(true);
            }

            var versionComparisionResult = compareEvrPart(firstEvr.Version, secondEvr.Version);

            if (versionComparisionResult.Equals(expectedResult))
            {
                return(true);
            }

            var releaseComparisionResult = compareEvrPart(firstEvr.Release, secondEvr.Release);

            if (releaseComparisionResult.Equals(expectedResult))
            {
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public void Should_be_possible_to_get_epoch_version_and_release_from_an_EvrString()
        {
            var evrStringSample = new EvrString("4:1.2-6");

            Assert.AreEqual("4", evrStringSample.Epoch, "Unexpected epoch was found in EVR String.");
            Assert.AreEqual("1.2", evrStringSample.Version, "Unexpected version was found in EVR String.");
            Assert.AreEqual("6", evrStringSample.Release, "Unexpected release was found in EVR String.");
        }
Exemple #5
0
        public void Should_be_possible_to_represent_an_EvrString_without_epoch_defined()
        {
            var evrStringSample = new EvrString("1.9-1");

            Assert.IsTrue(String.IsNullOrEmpty(evrStringSample.Epoch), String.Format("Epoch must be null or empty, but it contains '{0}'.", evrStringSample.Epoch));
            Assert.AreEqual("1.9", evrStringSample.Version, "Unexpected version was found in EVR String.");
            Assert.AreEqual("1", evrStringSample.Release, "Unexpected release was found in EVR String.");
        }
Exemple #6
0
        private bool ProcessEvrComparisionForEquals(EvrString firstEvr, EvrString secondEvr)
        {
            var epochComparisionResult = compareEpoches(firstEvr.Epoch, secondEvr.Epoch);

            if (epochComparisionResult.Equals(ComparisionResults.IsEqual))
            {
                var versionComparisionResult = compareEvrPart(firstEvr.Version, secondEvr.Version);
                if (versionComparisionResult.Equals(ComparisionResults.IsEqual))
                {
                    var releaseComparisionResult = compareEvrPart(firstEvr.Release, secondEvr.Release);
                    return(releaseComparisionResult.Equals(ComparisionResults.IsEqual));
                }
            }

            return(false);
        }
Exemple #7
0
        private bool ProcessEvrComparisionForEquals(EvrString firstEvr, EvrString secondEvr)
        {
            var epochComparisionResult = compareEpoches(firstEvr.Epoch, secondEvr.Epoch);
            if (epochComparisionResult.Equals(ComparisionResults.IsEqual))
            {
                var versionComparisionResult = compareEvrPart(firstEvr.Version, secondEvr.Version);
                if (versionComparisionResult.Equals(ComparisionResults.IsEqual))
                {
                    var releaseComparisionResult = compareEvrPart(firstEvr.Release, secondEvr.Release);
                    return releaseComparisionResult.Equals(ComparisionResults.IsEqual);
                }
            }

            return false;
        }
Exemple #8
0
        private bool ProcessEvrComparisionFor(EvrString firstEvr, EvrString secondEvr, ComparisionResults expectedResult)
        {
            var epochComparisionResult = compareEpoches(firstEvr.Epoch, secondEvr.Epoch);
            if (epochComparisionResult.Equals(expectedResult))
                return true;

            var versionComparisionResult = compareEvrPart(firstEvr.Version, secondEvr.Version);
            if (versionComparisionResult.Equals(expectedResult))
                return true;

            var releaseComparisionResult = compareEvrPart(firstEvr.Release, secondEvr.Release);
            if (releaseComparisionResult.Equals(expectedResult))
                return true;

            return false;
        }