Beispiel #1
0
        /// <summary>
        /// Compares the Right and Left strings
        /// </summary>
        /// <returns></returns>
        public ComparisonResultModel Compare()
        {
            var result = new ComparisonResultModel();

            if (string.IsNullOrEmpty(Right))
            {
                result.Info = "Unable to compare,Right string is missing";
            }
            if (string.IsNullOrEmpty(Left))
            {
                result.Info = "Unable to compare,Left string is missing";
            }

            //check that the strings are equal
            if (_stringComparerService.AreEqual(Right, Left))
            {
                result.Result = StringComparisonResult.Equal;
                result.Info   = "The two sides are equal";
                return(result);
            }

            //check that the strings are not of equal size
            if (!_stringComparerService.AreOfEqualSize(Right, Left))
            {
                result.Result = StringComparisonResult.NotOfEqualSize;
                result.Info   = "The two sides are not of equal size";
            }
            else
            {
                result.Result = StringComparisonResult.EqualSize;
                //check for differences in the strings, if any
                var diff = _stringComparerService.FindDiffinEqualSizeStrings(Right, Left);
                result.Info = "The two sides are of equal size";
                if (diff != null && diff.Any())
                {
                    result.Diff = diff;
                    result.Info = result.Info += ", but some differences in content were detected.";
                }
            }
            return(result);
        }
Beispiel #2
0
 public void Base64StringComparerAreOfEqualSizeReturnsTrue(string str1, string str2)
 {
     Assert.IsTrue(_comparer.AreOfEqualSize(str1, str2), string.Format("strings are not equal in size: str1  size is {0} and str2  size is {1}", str1.Length, str2.Length));
 }