コード例 #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);
        }
コード例 #2
0
 public void Base64StringComparerAreEqualReturnTrue(string str1, string str2)
 {
     Assert.IsTrue(_comparer.AreEqual(str1, str2), string.Format("strings are not equal str1 is {0} and str2 is {1}", str1, str2));
 }