public void Throws_Exeption_If_Entry_Is_Null()
        {
            // Act
            var ex = Record.Exception(() => _objectToTest.ValidateNotNullEntity(null));

            // Assert
            using (new AssertionScope())
            {
                ex.Should().NotBeNull();
                ex.Should().BeOfType(typeof(EntityNotFoundException));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the diff result for the given entry comparing the left and right side.
        /// Throws EntityNotFoundException if the id does not match any entry in the DB
        /// Throwa InvalidInputException if either left or rigth are null or contain an non base64 encoded string
        /// </summary>
        /// <param name="id">Id of the record to diff</param>
        /// <returns>A result containing the Status (equal, not equal o different size) and a collection of the offset and length of each difference found</returns>
        public async Task <DiffResult> GetDiff(Guid id)
        {
            var entry = await _entryRepository.GetByExternalId(id);

            _entryValidator.ValidateNotNullEntity(entry);
            _base64Validator.ValidateEntry(entry);

            var leftByteArray  = GetByteArray(entry.LeftSide);
            var rightByteArray = GetByteArray(entry.RightSide);

            if (leftByteArray.Length != rightByteArray.Length)
            {
                return(new DiffResult(DiffStatus.UnmatchedSize));
            }

            var diffs = _diffCalculator.GetComputedDiffs(leftByteArray, rightByteArray);

            return(new DiffResult(diffs));
        }