コード例 #1
0
        public void Base64StringComparerFindDiffinEqualSizeStringThrowsArgumentExceptions(string str1, string str2)
        {
            var parameters = new object[] { str1, str2 };

            Assert.ThrowsException <ArgumentException>(() =>
            {
                _comparer.FindDiffinEqualSizeStrings(str1, str2);
            }, string.Empty, null);
        }
コード例 #2
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);
        }