コード例 #1
0
ファイル: UnitTest.cs プロジェクト: luisfb/waes-assignment
        private void GivenTwoDifferentSizeBase64()
        {
            _repository.GetLeftBase64(_key).Returns(_base64Data1);
            _repository.GetRightBase64(_key).Returns(_base64Data3);

            _diffService = new DiffService(_repository);
        }
コード例 #2
0
        public DiffResult CompareLeftAndRightFiles(string key)
        {
            var left  = _repository.GetLeftBase64(key);
            var right = _repository.GetRightBase64(key);

            if (string.IsNullOrEmpty(left))
            {
                return new DiffResult {
                           Messages = new List <string>()
                           {
                               "Left base64 must be provided"
                           }
                }
            }
            ;

            if (string.IsNullOrEmpty(right))
            {
                return new DiffResult {
                           Messages = new List <string>()
                           {
                               "Right base64 must be provided"
                           }
                }
            }
            ;

            var leftByteArray  = Convert.FromBase64String(left);
            var rightByteArray = Convert.FromBase64String(right);

            if (leftByteArray.LongLength != rightByteArray.LongLength)
            {
                return(new DiffResult
                {
                    DifferentSize = true,
                    Messages = new List <string> {
                        "Both files must be of same size."
                    }
                });
            }

            return(CompareBytes(leftByteArray, rightByteArray));
        }