public ComparisonResultViewModel Compare(string leftEntity, string rightEntity, string leftAlias, string rightAlias, string targetDatabase, bool isEncrypted = false) { ComparedEntity leftComparisonEntity; ComparedEntity rightComparisonEntity; try { leftComparisonEntity = _entityFactory.Create(leftEntity); rightComparisonEntity = _entityFactory.Create(rightEntity); } catch (Exception e) { _logger.LogError(e.Message); _logger.LogError(e.StackTrace); return(null); } var compareOptions = new CompareOptions { IgnoreEndOfFile = _optionsService.ComparisonSettings.IgnoreEndOfFile, IgnoreNewLines = _optionsService.ComparisonSettings.IgnoreNewLines, IgnoreWhitespace = _optionsService.ComparisonSettings.IgnoreWhitespace, CaseInsensitive = _optionsService.ComparisonSettings.CaseInsensitive }; var comparisonResult = _comparer.Compare(compareOptions, leftComparisonEntity, rightComparisonEntity).Single(); if (leftAlias == rightAlias) { comparisonResult.Outcome = ComparisonOutcome.SameObject; } return(new ComparisonResultViewModel { ComparisonResult = comparisonResult, LeftAlias = leftAlias, RightAlias = rightAlias, TargetDatabase = targetDatabase, LeftEntity = leftEntity, RightEntity = rightEntity, IsEncrypted = isEncrypted, }); }
public void SqlComparer_TwoEntities_DifferentContent() { var proc1 = _entityFactory.Create( $@"create procedure Schema1.name as select * from Users"); var proc2 = _entityFactory.Create( $@"create procedure Schema1.name as select * from Others"); var comparisonResult = _comparer.Compare(_compareOptions, proc1, proc2).ToArray(); Assert.AreEqual(comparisonResult.Single().Outcome, ComparisonOutcome.Different); Assert.IsFalse(comparisonResult.Single().LeftEntity.HasParseErrors); Assert.IsFalse(comparisonResult.Single().RightEntity.HasParseErrors); Assert.IsTrue(comparisonResult.Single().LinesDifferingInLeftEntity.Contains(4)); Assert.IsTrue(comparisonResult.Single().LinesDifferingInRightEntity.Contains(4)); }