private bool TestFlag(DifferenceType d1, DifferenceType d2) { int a = (int)d1; int b = (int)d2; return((a & b) > 0); }
public ComparisonResult(String aSourcePath, String aDestPath, DifferenceType aType, bool aIsFile) { SourcePath = aSourcePath; Destinations = new List <Destination>(); Destinations.Add(new Destination(aDestPath, aType)); IsFile = aIsFile; }
/// <summary> /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </returns> public override string ToString() { string retVal = Item + ": "; switch (DifferenceType) { case DifferenceType.Created: case DifferenceType.Modified: case DifferenceType.Removed: retVal = retVal + DifferenceType; break; case DifferenceType.CreatedPermission: retVal = retVal + "Permission created for " + Item; break; case DifferenceType.Dependency: retVal = retVal + "Recreated for a dependency on " + ParentItem; break; case DifferenceType.TableData: retVal = ParentItem + ": Table Data"; break; default: throw new Exception(DifferenceType.ToString()); } foreach (string message in Messages) { retVal = retVal + "\n\t" + message; } return(retVal); }
private static void WriteDiff(StreamWriter writer, DiffApiDefinition api, int level) { bool hasChildren = api.Children.Any(); string indent = new string(' ', level * 4); string suffix = hasChildren ? " {" : string.Empty; DifferenceType diff = api.Difference; if (diff == DifferenceType.Changed) { // Let's see whether the syntax actually changed. For some cases the syntax might not // diff, for example, when attribute declarations have changed. string left = api.Left.GetCSharpDeclaration(); string right = api.Right.GetCSharpDeclaration(); if (string.Equals(left, right, StringComparison.OrdinalIgnoreCase)) { diff = DifferenceType.Unchanged; } } switch (diff) { case DifferenceType.Added: WriteDiff(writer, "+", indent, suffix, api.Right); break; case DifferenceType.Removed: WriteDiff(writer, "-", indent, suffix, api.Left); break; case DifferenceType.Changed: WriteDiff(writer, "-", indent, suffix, api.Left); WriteDiff(writer, "+", indent, suffix, api.Right); break; default: WriteDiff(writer, " ", indent, suffix, api.Definition); break; } if (hasChildren) { foreach (DiffApiDefinition child in api.Children) { WriteDiff(writer, child, level + 1); } var diffMarker = diff == DifferenceType.Added ? "+" : diff == DifferenceType.Removed ? "-" : " "; writer.Write(diffMarker); writer.Write(indent); writer.WriteLine("}"); } }
public static Difference GetDifferences(string absoluteFileA, string absoluteFileB) { JObject aInfo = JObject.Parse(File.ReadAllText(absoluteFileA)); JObject bInfo = JObject.Parse(File.ReadAllText(absoluteFileB)); DifferenceType aType = GetDifferenceType(aInfo); DifferenceType bType = GetDifferenceType(bInfo); if (aType != bType) { throw new InvalidDifferenceException($"{absoluteFileA} and {absoluteFileB} have different underlying types: {aType} and {bType}"); } Console.WriteLine(aType); switch (aType) { case DifferenceType.Dictionary: return(DictionaryDifferenceGenerator.GetDifference(aInfo, bInfo)); case DifferenceType.Image: return(ImageDifferenceGenerator.GetDifference(absoluteFileA, absoluteFileB)); default: return(null); } }
public DifferenceItem(string text, DifferenceType type, Maybe <int> position) { Text = text; Type = type; Position = position; subItems = new List <DifferenceItem>(); }
public Difference(DifferenceType differenceType, string propertyName, string sourceValue, string targetValue) { this.DifferenceType = differenceType; this.PropertyName = propertyName; this.SourceValue = sourceValue; this.TargetValue = targetValue; }
public DifferenceHandlerAttribute(int type, DifferenceType differenceType, int priority) { // Set fields this.Type = type; this.DifferenceType = differenceType; this.Priority = priority; }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. This overload does not /// check for the starting and ending references for sub-diffs that are created without /// that information. /// </summary> /// <param name="rootDiff">The root difference.</param> /// <param name="iSubDiff">The sub difference to verify.</param> /// <param name="subDiffType">Type of the sub difference.</param> /// <param name="footnoteCurr">The footnote curr.</param> /// <param name="ichMinCurr">The beginning character offset of the difference in the /// current.</param> /// <param name="ichLimCurr">The ending character offset of the difference in the /// current.</param> /// <param name="footnoteRev">The footnote rev.</param> /// <param name="ichMinRev">The beginning character offset of the difference in the /// revision.</param> /// <param name="ichLimRev">The ending character offset of the difference in the /// current.</param> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffFootnote(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, IScrFootnote footnoteCurr, int ichMinCurr, int ichLimCurr, IScrFootnote footnoteRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForORCs[iSubDiff]; // the Current para stuff Assert.AreEqual((footnoteCurr != null) ? footnoteCurr.ParagraphsOS[0] : null, subDiff.ParaCurr); Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr); Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr); // the Revision para stuff Assert.AreEqual((footnoteRev != null) ? footnoteRev.ParagraphsOS[0] : null, subDiff.ParaRev); Assert.AreEqual(ichMinRev, subDiff.IchMinRev); Assert.AreEqual(ichLimRev, subDiff.IchLimRev); // section stuff should be null Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsCurr); // subDiffs may not have subDiffs, so far Assert.IsNull(subDiff.SubDiffsForORCs); Assert.IsNull(subDiff.SubDiffsForParas); Assert.AreEqual(subDiffType, subDiff.DiffType); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given base difference /// that deals with changes in paragraph structure. /// </summary> /// <remarks>char styles and subDiffs are not verified here; test code should just check /// those directly if relevant</remarks> /// <param name="diff">the given Difference.</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaStructDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type) { // verify the basics Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); // Subdifferences must exist. Assert.IsNotNull(diff.SubDiffsForParas, "Subdifferences should have been created."); Assert.Greater(diff.SubDiffsForParas.Count, 0, "Subdifferences should have been created."); Difference firstSubdiff = diff.SubDiffsForParas[0]; // the Current para stuff should be the same as the start of the first subdiff Assert.AreEqual(firstSubdiff.ParaCurr, diff.ParaCurr); Assert.AreEqual(firstSubdiff.IchMinCurr, diff.IchMinCurr); Assert.AreEqual(firstSubdiff.IchMinCurr, diff.IchLimCurr); // the Revision para stuff should be the same as the start of the first subdiff also Assert.AreEqual(firstSubdiff.ParaRev, diff.ParaRev); Assert.AreEqual(firstSubdiff.IchMinRev, diff.IchMinRev); Assert.AreEqual(firstSubdiff.IchMinRev, diff.IchLimRev); // section stuff should be null Assert.IsNull(diff.SectionsRev); Assert.IsNull(diff.SectionsCurr); }
public override int GetHashCode() { var hashCode = 862207841; hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(BasePath); foreach (var excludedDirectory in ExcludedDirectories) { hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode( excludedDirectory); } foreach (var fileExtension in FileExtensions) { hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode( fileExtension); } hashCode = (hashCode * -1521134295) + Recursive.GetHashCode(); hashCode = (hashCode * -1521134295) + DifferenceType.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDurationDifferenceSeconds.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDurationDifferencePercent.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxImageCompares.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDifferentImages.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxImageDifferencePercent.GetHashCode(); return(hashCode); }
public async Task SavesDiffToDataDir(int diffId, DifferenceType type, int offset) { var content = new DifferenceContent { Type = type, Details = new[] { new DifferenceDetail { LeftOffset = offset }, new DifferenceDetail { RightOffset = offset }, } }; var expectedFileName = Path.Combine(_DataDir, string.Concat(diffId.ToString(), ".diff")); File.Delete(expectedFileName); var storage = new DiskStorage(_Options); await storage.SaveDiffAsync(content.InDiffBag(diffId)); File.ReadAllText(expectedFileName) .Should().Be(JsonConvert.SerializeObject(content)); }
/// <summary> /// Instantiate a new object representing the compatibility difference. /// </summary> /// <param name="id"><see cref="string"/> representing the diagnostic ID.</param> /// <param name="message"><see cref="string"/> message describing the difference.</param> /// <param name="type"><see cref="DifferenceType"/> to describe the type of the difference.</param> /// <param name="memberId"><see cref="string"/> containing the member ID for which the difference is associated to.</param> public CompatDifference(string diagnosticId, string message, DifferenceType type, string memberId) { DiagnosticId = diagnosticId ?? throw new ArgumentNullException(nameof(diagnosticId)); Message = message ?? throw new ArgumentNullException(nameof(message)); Type = type; ReferenceId = memberId ?? throw new ArgumentNullException(nameof(memberId)); }
public static async Task CallDifferenceHandlers(int fileType, DifferenceType differenceType, object[] parameters) { // Get the handlers SortedList <int, MethodInfo> methodInfos = HandlerMapper.GetHandlers((int)fileType, differenceType); // Loop over every handler foreach (MethodInfo methodInfo in methodInfos.Values) { await DiscordBot.LoggingChannel.SendMessageAsync("**[BCAT]** Calling " + methodInfo.DeclaringType.Name + "." + methodInfo.Name + "()"); try { // Invoke the method object returnValue = methodInfo.Invoke(null, parameters); // Check the return value if (returnValue != null && returnValue is Task) { await(Task) returnValue; } } catch (Exception exception) { // Notify the logging channel await DiscordUtil.HandleException((exception is TargetInvocationException)?((TargetInvocationException)exception).InnerException : exception, $"in ``{methodInfo.DeclaringType.Name}.{methodInfo.Name}()``"); } } }
public CompatDifference(string id, string message, DifferenceType type, string memberId) { DiagnosticId = id; Message = message; Type = type; ReferenceId = memberId; }
[SetUp] public void CreateMinorDifference() { DifferenceType id = DifferenceType.ATTR_SEQUENCE_ID; Assertion.AssertEquals(false, Differences.isMajorDifference(id)); minorDifference = new Difference(id); }
public RowDifference(SnapshotRowKey key, DifferenceType differenceType, SnapshotRow before, SnapshotRow after) { Key = key; DifferenceType = differenceType; Before = before; After = after; }
[SetUp] public void CreateMinorDifference() { DifferenceType id = DifferenceType.ATTR_SEQUENCE_ID; Assert.IsFalse(Differences.isMajorDifference(id)); minorDifference = new Difference(id); }
[SetUp] public void CreateMinorDifference() { DifferenceType id = DifferenceType.AttributeSequence; Assert.AreEqual(false, Differences.isMajorDifference(id)); minorDifference = new Difference(id); }
public ThreatsDifference(DifferenceType differenceType, Threat oldThreat, Threat newThreat) { DifferenceType = differenceType; OldThreat = oldThreat; NewThreat = newThreat; DifferentFieldsNames = GetDifferentFieldsNames(); }
/// <summary> /// Provides a hash function for the type. /// </summary> public override int GetHashCode() { int callbackHashCode = (DetermineLocalityCallback != null) ? DetermineLocalityCallback.GetHashCode() : 0; int predicateHashCode = (ContinueProcessingPredicate != null)? ContinueProcessingPredicate.GetHashCode() : 0; return(DifferenceType.GetHashCode() ^ Locality.GetHashCode() ^ IgnoreTrimWhiteSpace.GetHashCode() ^ WordSplitBehavior.GetHashCode() ^ callbackHashCode ^ predicateHashCode); }
public async Task LoadsReadyDiffFromDataDir(int diffId, DifferenceType type, int length) { var content = new DifferenceContent { Type = type, Details = new[] { new DifferenceDetail { LeftLength = length }, new DifferenceDetail { RightLength = length }, } }; var expectedFileName = Path.Combine(_DataDir, string.Concat(diffId.ToString(), ".diff")); File.WriteAllText(expectedFileName, JsonConvert.SerializeObject(content)); try { var storage = new DiskStorage(_Options); var(diff, readiness) = await storage.LoadDiffAsync(diffId); readiness.Should().Be(DifferenceReadiness.Ready); diff.Type.Should().Be(type); diff.Details.ShouldAllBeEquivalentTo(content.Details, opts => opts.WithStrictOrdering()); } finally { File.Delete(expectedFileName); } }
private void DifferenceFound(DifferenceType differenceType, XmlNodeType controlNodeType, XmlNodeType testNodeType, DiffResult result) { DifferenceFound(new Difference(differenceType, controlNodeType, testNodeType), result); }
protected override Difference getDifference(DifferenceType differenceType, DatabaseObjectBase fromObject, DatabaseObjectBase toObject = null, string propertyName = null, string sourceValue = null, string targetValue = null) { if (propertyName != null && propertyName == "ForeignKeyName" && differenceType == DifferenceType.Alter && !fromObject.Database.DataSource.NamedConstraints) { return(null); } return(base.getDifference(differenceType, fromObject, toObject, propertyName, sourceValue, targetValue)); }
public RowDifference(SnapshotRowKey key, RowDataCompareResult differences, DifferenceType type) { Key = key; DifferenceType = type; Differences = differences; Before = differences.Before; After = differences.After; }
/// <summary> /// Initializes a new instance of the <see cref="Difference"/> class. /// </summary> /// <param name="differenceType">Type of the difference.</param> /// <param name="item">The item with a difference.</param> /// <param name="parentItem">The parent item.</param> public Difference(DifferenceType differenceType, string item, string parentItem) { DifferenceType = differenceType; Item = item; ParentItem = parentItem; Messages = new List <string>(); }
/// <summary> /// Initializes a new instance of the <see cref="DetectedChanges"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="path">The path.</param> /// <param name="sourceValue">The source value.</param> /// <param name="targetValue">The target value.</param> public DetectedChanges(DifferenceType type, string path, string sourceValue, string targetValue) { Side = MissedSide.Target; Type = type; Path = path; HasValues = true; SourceValue = sourceValue; TargetValue = targetValue; }
/// <summary>overload for same end ref, same ichRev</summary> public static void VerifyParaDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara paraRev, int ichRev) { VerifyParaDiff(diff, startAndEnd, startAndEnd, type, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichRev, ichRev); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines whether the specified type of difference is one which, if "Use this /// Version" (i.e., revert to old) is clicked, would result in deletion of a significant /// amount of data (a whole verse or more). /// </summary> /// <param name="diffType">Type of the diff.</param> /// ------------------------------------------------------------------------------------ internal static bool IsParagraphAdditionOrDeletion(DifferenceType diffType) { return((diffType & DifferenceType.ParagraphAddedToCurrent) != 0 || (diffType & DifferenceType.ParagraphMissingInCurrent) != 0 || (diffType & DifferenceType.SectionHeadAddedToCurrent) != 0 || (diffType & DifferenceType.SectionHeadMissingInCurrent) != 0 || (diffType & DifferenceType.SectionAddedToCurrent) != 0 || (diffType & DifferenceType.SectionMissingInCurrent) != 0); }
/// <summary>overload for same end ref</summary> public static void VerifyParaDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { VerifyParaDiff(diff, startAndEnd, startAndEnd, type, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichMinRev, ichLimRev); }
public static bool isMajorDifference(DifferenceType differenceType) { switch (differenceType) { case DifferenceType.AttributeSequence: return false; case DifferenceType.HAS_XML_DECLARATION_PREFIX_ID: return false; default: return true; } }
private void EnsureDiff() { if (_differences != null) { return; } _differences = new List <Difference>(); _difference = GetMappingDifference(); }
public static bool isMajorDifference(DifferenceType differenceType) { switch (differenceType) { case DifferenceType.EMPTY_NODE_ID: // Fall through case DifferenceType.ATTR_SEQUENCE_ID: // Fall through case DifferenceType.HAS_XML_DECLARATION_PREFIX_ID: return false; default: return true; } }
public static Boolean isMajorDifference(DifferenceType differenceType) { switch (differenceType) { case DifferenceType.ATTR_SEQUENCE_ID: return false; case DifferenceType.HAS_XML_DECLARATION_PREFIX_ID: return false; default: return true; } }
public void Many_Disabled_Objects_With_Same_ApplicationName_DifferenceType_Can_Exist(DifferenceType differenceType, ValidationState validationState) { var ruleSet = new RuleSet(); var persistentApplication = new PersistentApplication(Session.DefaultSession); new ModelDifferenceObject(Session.DefaultSession) { Disabled = true, PersistentApplication = persistentApplication }.Save(); var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession) { Disabled = true, PersistentApplication = persistentApplication }; Isolate.WhenCalled(() => modelDifferenceObject.DifferenceType).WillReturn(differenceType); RuleSetValidationResult target = ruleSet.ValidateTarget(modelDifferenceObject, ContextIdentifier.Save); var resultItem = target.Results.Where(item => item.Rule is RuleCombinationOfPropertiesIsUnique).Single(); Assert.AreEqual(validationState, resultItem.State); }
public void DateCreated_Can_Not_Be_Null(DifferenceType differenceType, ValidationState validationState) { var o = new ModelDifferenceObject(Session.DefaultSession); Isolate.WhenCalled(() => o.DifferenceType).WillReturn(differenceType); var ruleSet = new RuleSet(); RuleSetValidationResult target = ruleSet.ValidateTarget(o, ContextIdentifier.Save); RuleSetValidationResultItem @default = target.Results.Where( item => item.Rule is RuleRequiredField && ((RuleRequiredField)item.Rule).TargetMember.Name == o.GetPropertyInfo(x => x.DateCreated).Name).FirstOrDefault(); Assert.AreEqual(validationState, @default.State); }
public void Same_Application_Objets_Cannot_Exist(DifferenceType differenceType, ValidationState validationState) { var ruleSet = new RuleSet(); var persistentApplication = new PersistentApplication(Session.DefaultSession); var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession) { PersistentApplication = persistentApplication }; modelDifferenceObject.Save(); var modelDifferenceObject1 = new ModelDifferenceObject(Session.DefaultSession) { PersistentApplication = persistentApplication }; Isolate.WhenCalled(() => modelDifferenceObject1.DifferenceType).WillReturn(differenceType); RuleSetValidationResult target = ruleSet.ValidateTarget(modelDifferenceObject1, ContextIdentifier.Save); Assert.IsInstanceOfType(typeof(RuleCombinationOfPropertiesIsUnique), target.Results[0].Rule); Assert.AreEqual(validationState, target.Results[0].State); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for any types that deal with changes in a paragraph. /// </summary> /// <remarks>char styles and subDiffs are not verified here; test code should just check /// those directly if relevant</remarks> /// <param name="diff">the given Difference.</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraCurr">The Current paragraph.</param> /// <param name="ichMinCurr">The ich min in paraCurr.</param> /// <param name="ichLimCurr">The ich lim in paraCurr.</param> /// <param name="paraRev">The Revision paragraph.</param> /// <param name="ichMinRev">The ich min in paraRev.</param> /// <param name="ichLimRev">The ich lim in paraRev.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { // verify the basics Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); // the Current para stuff Assert.AreEqual(paraCurr.Hvo, diff.HvoCurr); Assert.AreEqual(ichMinCurr, diff.IchMinCurr); Assert.AreEqual(ichLimCurr, diff.IchLimCurr); // the Revision para stuff Assert.AreEqual(paraRev.Hvo, diff.HvoRev); Assert.AreEqual(ichMinRev, diff.IchMinRev); Assert.AreEqual(ichLimRev, diff.IchLimRev); // section stuff should be null Assert.IsNull(diff.HvosSectionsRev); Assert.IsNull(diff.HvosSectionsCurr); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference and given SubDiffForParas /// for subdiff types: missing/added paragraphs. /// </summary> /// <param name="rootDiff">The root diff.</param> /// <param name="iSubDiff">The para subdiff index.</param> /// <param name="subDiffType">diffType of the subdiff.</param> /// <param name="paraAdded">The para added.</param> /// <param name="ichLim">The ichlim for the paraAdded. Often this may be the end of the para, /// or it may indicate only the first portion (ScrVerse) of the final paragraph.</param> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffParaAdded(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, StTxtPara paraAdded, int ichLim) { Assert.AreEqual(DifferenceType.ParagraphStructureChange, rootDiff.DiffType); // a ParaAdded/Missing subDiff must not be at index 0 (paragraph reference points must be in that subdiff Assert.LessOrEqual(1, iSubDiff); Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; Assert.AreEqual(subDiffType, subDiff.DiffType); switch (subDiffType) { case DifferenceType.ParagraphAddedToCurrent: Assert.AreEqual(paraAdded.Hvo, subDiff.HvoCurr); Assert.AreEqual(0, subDiff.IchMinCurr); Assert.AreEqual(ichLim, subDiff.IchLimCurr); //subDiff may be only first portion of the final paragraph Assert.AreEqual(0, subDiff.HvoRev); Assert.AreEqual(0, subDiff.IchMinRev); Assert.AreEqual(0, subDiff.IchLimRev); break; case DifferenceType.ParagraphMissingInCurrent: Assert.AreEqual(0, subDiff.HvoCurr); Assert.AreEqual(0, subDiff.IchMinCurr); Assert.AreEqual(0, subDiff.IchLimCurr); Assert.AreEqual(paraAdded.Hvo, subDiff.HvoRev); Assert.AreEqual(0, subDiff.IchMinRev); Assert.AreEqual(ichLim, subDiff.IchLimRev); //subDiff may be only first portion of the final paragraph break; default: Assert.Fail("Invalid subDiff type for a Paragraph Added/Missing subDiff"); break; } Assert.IsNull(subDiff.HvosSectionsRev); Assert.IsNull(subDiff.HvosSectionsRev); Assert.IsNull(subDiff.StyleNameCurr); Assert.IsNull(subDiff.StyleNameRev); Assert.IsNull(subDiff.SubDiffsForORCs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. This overload does not /// check for the starting and ending references for sub-diffs that are created without /// that information. /// </summary> /// <param name="rootDiff">The root difference.</param> /// <param name="iSubDiff">The sub difference to verify.</param> /// <param name="subDiffType">Type of the sub difference.</param> /// <param name="footnoteCurr">The footnote curr.</param> /// <param name="ichMinCurr">The beginning character offset of the difference in the /// current.</param> /// <param name="ichLimCurr">The ending character offset of the difference in the /// current.</param> /// <param name="footnoteRev">The footnote rev.</param> /// <param name="ichMinRev">The beginning character offset of the difference in the /// revision.</param> /// <param name="ichLimRev">The ending character offset of the difference in the /// current.</param> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffFootnote(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, StFootnote footnoteCurr, int ichMinCurr, int ichLimCurr, StFootnote footnoteRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForORCs[iSubDiff]; // the Current para stuff Assert.AreEqual((footnoteCurr != null) ? footnoteCurr.ParagraphsOS[0].Hvo : 0, subDiff.HvoCurr); Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr); Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr); // the Revision para stuff Assert.AreEqual((footnoteRev != null) ? footnoteRev.ParagraphsOS[0].Hvo : 0, subDiff.HvoRev); Assert.AreEqual(ichMinRev, subDiff.IchMinRev); Assert.AreEqual(ichLimRev, subDiff.IchLimRev); // section stuff should be null Assert.IsNull(subDiff.HvosSectionsRev); Assert.IsNull(subDiff.HvosSectionsCurr); // subDiffs may not have subDiffs, so far Assert.IsNull(subDiff.SubDiffsForORCs); Assert.IsNull(subDiff.SubDiffsForParas); Assert.AreEqual(subDiffType, subDiff.DiffType); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the text change label for the specified type of difference. /// </summary> /// <param name="differenceType">Type of the difference.</param> /// <returns>localized string from the resources representing the difference type, or /// string.Empty if the type was not expected.</returns> /// ------------------------------------------------------------------------------------ private string GetTextChangeLabel(DifferenceType differenceType) { switch (differenceType) { case DifferenceType.TextDifference: return TeDiffViewResources.kstidTextChanged; case DifferenceType.CharStyleDifference: return TeDiffViewResources.kstidCharacterStyleDiff; case DifferenceType.MultipleCharStyleDifferences: return TeDiffViewResources.kstidMultipleStyleDiffs; case DifferenceType.FootnoteAddedToCurrent: return TeDiffViewResources.kstidFootnoteAdded; case DifferenceType.FootnoteMissingInCurrent: return TeDiffViewResources.kstidFootnoteDeleted; case DifferenceType.FootnoteDifference: return TeDiffViewResources.kstidFootnoteDifference; case DifferenceType.PictureDifference: return TeDiffViewResources.kstidPictureDifference; case DifferenceType.PictureMissingInCurrent: return TeDiffViewResources.kstidPictureMissing; case DifferenceType.WritingSystemDifference: return TeDiffViewResources.kstidWritingSystemDiff; default: Debug.Fail("Unexpected difference type: " + differenceType.ToString()); break; } return string.Empty; }
/// <summary> /// Load the results of the comparison for the specified difference type /// </summary> /// <param name="diffType">Enum variable to identify the type of difference(None, Add, Update, Remove)</param> private void LoadGrid(DifferenceType diffType) { int count = 0; DataGridView grid; TabPage tab; switch (diffType) { case DifferenceType.Add: grid = gridAdd; tab = tabAdd; break; case DifferenceType.Update: grid = gridUpdate; tab = tabUpdate; break; case DifferenceType.Delete: grid = gridDelete; tab = tabRemove; break; case DifferenceType.None: grid = gridNone; tab = tabNone; break; default: throw new ArgumentOutOfRangeException("diffType"); } grid.Rows.Clear(); grid.Columns.Clear(); DataGridViewColumn chkColumn = new CustomGridViewCheckBoxColumn(); chkColumn.MinimumWidth = 26; grid.Columns.Add(chkColumn); DataGridViewColumn iconColumn = new DataGridViewImageColumn(); iconColumn.MinimumWidth = 26; grid.Columns.Add(iconColumn); DataGridViewColumn nameColumn = new DataGridViewTextBoxColumn(); nameColumn.HeaderText = "Object Name"; grid.Columns.Add(nameColumn); foreach (DifferenceModel dm in differencesFound.Where(x => x.DiffType == diffType).OrderBy(y => y.ObjectKind).ThenBy(z => z.Name)) { grid.Rows.Add(false, GetIconFor(dm.ObjectKind), dm.Name); count++; } tab.Text = String.Format("{0}({1})", tab.Text.IndexOf('(') >= 0 ? tab.Text.Substring(0, tab.Text.IndexOf('(')) : tab.Text, count); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for types: missing/added paragraphs. /// </summary> /// <param name="diff">the given Difference</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraAdded">The paragraph added.</param> /// <param name="paraDest">the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaAddedDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, StTxtPara paraAdded, StTxtPara paraDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.ParagraphAddedToCurrent: Assert.IsNull(diff.HvosSectionsRev); Assert.AreEqual(paraAdded.Hvo, diff.HvoCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimCurr); Assert.AreEqual(paraDest.Hvo, diff.HvoRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.ParagraphMissingInCurrent: Assert.IsNull(diff.HvosSectionsRev); Assert.AreEqual(paraDest.Hvo, diff.HvoCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(paraAdded.Hvo, diff.HvoRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; } }
public Difference(DifferenceType id, XmlNodeType controlNodeType, XmlNodeType testNodeType) : this(id) { _controlNodeType = controlNodeType; _testNodeType = testNodeType; }
public Difference(DifferenceType id) { _diffType = id; _hasMajorDifference = Differences.isMajorDifference(id); }
public virtual bool Include(DifferenceType difference) { return _include(difference); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// of type Missing/Added Section/SectionHead. /// </summary> /// <remarks>subDiffs are not verified here; test code should check those directly /// if relevant</remarks> /// <param name="diff">the given Difference</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// <param name="sectionsAdded">Sections that were added (this can be single one or an /// array of them; the code will be smart enough to figure out which and act accordingly)</param> /// <param name="paraDest">The destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifySectionDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, object sectionsAdded, IScrTxtPara paraDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.SectionAddedToCurrent: case DifferenceType.SectionHeadAddedToCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsCurr.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsCurr.First()); } else if (sectionsAdded is IScrSection[]) Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsCurr)); else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.SectionsRev); Assert.AreEqual(null, diff.ParaCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(0, diff.IchLimCurr); Assert.AreEqual(paraDest, diff.ParaRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.SectionMissingInCurrent: case DifferenceType.SectionHeadMissingInCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsRev.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsRev.First()); } else if (sectionsAdded is IScrSection[]) Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsRev)); else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.SectionsCurr); Assert.AreEqual(paraDest, diff.ParaCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(null, diff.ParaRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(0, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; default: Assert.Fail("test called wrong verify method or something"); break; } }
public Difference(DifferenceType id) { _id = id; _majorDifference = Differences.isMajorDifference(id); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines whether the specified type of difference is one which, if "Use this /// Version" (i.e., revert to old) is clicked, would result in deletion of a significant /// amount of data (a whole verse or more). /// </summary> /// <param name="diffType">Type of the diff.</param> /// ------------------------------------------------------------------------------------ internal static bool IsParagraphAdditionOrDeletion(DifferenceType diffType) { return ((diffType & DifferenceType.ParagraphAddedToCurrent) != 0 || (diffType & DifferenceType.ParagraphMissingInCurrent) != 0 || (diffType & DifferenceType.SectionHeadAddedToCurrent) != 0 || (diffType & DifferenceType.SectionHeadMissingInCurrent) != 0 || (diffType & DifferenceType.SectionAddedToCurrent) != 0 || (diffType & DifferenceType.SectionMissingInCurrent) != 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for types: missing/added empty paragraphs. /// </summary> /// <param name="diff">the given Difference</param> /// <param name="startAndEnd">The starting and ending verse ref start.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraAdded">The paragraph added.</param> /// <param name="paraDest">the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifyStanzaBreakAddedDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, StTxtPara paraAdded, /*string strAddedParaStyle,*/ StTxtPara paraDest, int ichDest) { Assert.IsTrue(diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent || diff.DiffType == DifferenceType.StanzaBreakMissingInCurrent); //string addedParaStyle = (diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent) ? // diff.StyleNameCurr : diff.StyleNameRev; //Assert.AreEqual(strAddedParaStyle, addedParaStyle); VerifyParaAddedDiff(diff, startAndEnd, startAndEnd, type, paraAdded, paraDest, ichDest); }
protected ModelApplicationBase CreateModelApplication(ModelApplicationBase model, DifferenceType differenceType) { var application = model.CreatorInstance.CreateModelApplication(); application.Id = Application.Title; return application; }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// of type Missing/Added Section/SectionHead. /// </summary> /// <remarks>subDiffs are not verified here; test code should check those directly /// if relevant</remarks> /// <param name="diff">the given Difference</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// <param name="hvosAdded">hvo(s) of the sections or paragraphs that were added (this can be /// an int or an int[], the code will be smart enough to figure out which and act accordingly)</param> /// <param name="hvoParaDest">The hvo of the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifySectionDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, object hvosAdded, int hvoParaDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.SectionAddedToCurrent: case DifferenceType.SectionHeadAddedToCurrent: if (hvosAdded is int) { Assert.AreEqual(1, diff.HvosSectionsCurr.Length); Assert.AreEqual(hvosAdded, diff.HvosSectionsCurr[0]); } else if (hvosAdded is int[]) { Assert.IsTrue( ArraysAreEqual((int[])hvosAdded, diff.HvosSectionsCurr)); //Assert.IsTrue(Array.Equals((int[])hvosAdded, diff.HvosSectionsCurr)); } else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.HvosSectionsRev); Assert.AreEqual(0, diff.HvoCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(0, diff.IchLimCurr); Assert.AreEqual(hvoParaDest, diff.HvoRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.SectionMissingInCurrent: case DifferenceType.SectionHeadMissingInCurrent: if (hvosAdded is int) { Assert.AreEqual(1, diff.HvosSectionsRev.Length); Assert.AreEqual(hvosAdded, diff.HvosSectionsRev[0]); } else if (hvosAdded is int[]) { Assert.IsTrue( ArraysAreEqual((int[])hvosAdded, diff.HvosSectionsRev)); //Assert.IsTrue(Array.Equals((int[])hvosAdded, diff.HvosSectionsRev)); } else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.HvosSectionsCurr); Assert.AreEqual(hvoParaDest, diff.HvoCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(0, diff.HvoRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(0, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; default: Assert.Fail("test called wrong verify method or something"); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given base difference /// that deals with changes in paragraph structure. /// </summary> /// <param name="diff">The diff.</param> /// <param name="startAndEnd">The starting and ending reference.</param> /// <param name="type">The difference type.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaStructDiff(Difference diff, BCVRef startAndEnd, DifferenceType type) { VerifyParaStructDiff(diff, startAndEnd, startAndEnd, type); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given base difference /// that deals with changes in paragraph structure. /// </summary> /// <remarks>char styles and subDiffs are not verified here; test code should just check /// those directly if relevant</remarks> /// <param name="diff">the given Difference.</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaStructDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type) { // verify the basics Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); // Subdifferences must exist. Assert.IsNotNull(diff.SubDiffsForParas, "Subdifferences should have been created."); Assert.Greater(diff.SubDiffsForParas.Count, 0, "Subdifferences should have been created."); Difference firstSubdiff = diff.SubDiffsForParas[0]; // the Current para stuff should be the same as the start of the first subdiff Assert.AreEqual(firstSubdiff.HvoCurr, diff.HvoCurr); Assert.AreEqual(firstSubdiff.IchMinCurr, diff.IchMinCurr); Assert.AreEqual(firstSubdiff.IchMinCurr, diff.IchLimCurr); // the Revision para stuff should be the same as the start of the first subdiff also Assert.AreEqual(firstSubdiff.HvoRev, diff.HvoRev); Assert.AreEqual(firstSubdiff.IchMinRev, diff.IchMinRev); Assert.AreEqual(firstSubdiff.IchMinRev, diff.IchLimRev); // section stuff should be null Assert.IsNull(diff.HvosSectionsRev); Assert.IsNull(diff.HvosSectionsCurr); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. /// </summary> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ //TODO: this is used only for VerseMoved subdiffs. rename it as VerifySubDiffVerseMoved. // provide logic appropriate for VerseMoved, and don't rely on VerifySubDiffTextCompared // Maybe just revert to the 2006 logic when VerseMoved was implemented. public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff, BCVRef start, BCVRef end, DifferenceType subDiffType, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; // verify the Scripture references Assert.AreEqual(start, subDiff.RefStart); Assert.AreEqual(end, subDiff.RefEnd); // verify everything else VerifySubDiffTextCompared(rootDiff, iSubDiff, subDiffType, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichMinRev, ichLimRev); }
public override void AfterConstruction() { base.AfterConstruction(); _differenceType = DifferenceType.Model; }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. This overload does not /// check for the starting and ending references for sub-diffs that are created without /// that information. /// </summary> /// <param name="rootDiff">The root difference.</param> /// <param name="iSubDiff">The sub difference to verify.</param> /// <param name="subDiffType">Type of the sub difference.</param> /// <param name="paraCurr">The current paragraph.</param> /// <param name="ichMinCurr">The beginning character offset of the difference in the /// current.</param> /// <param name="ichLimCurr">The ending character offset of the difference in the /// current.</param> /// <param name="paraRev">The revision paragraph.</param> /// <param name="ichMinRev">The beginning character offset of the difference in the /// revision.</param> /// <param name="ichLimRev">The ending character offset of the difference in the /// current.</param> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ //TODO: use an iSubDiff parameter instead of the subDiff itself; // use the following method as a model to verify the root diff type // make a separate method for footnote subdiffs public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; // the Current para stuff Assert.AreEqual((paraCurr != null) ? paraCurr.Hvo : 0, subDiff.HvoCurr); Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr); Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr); // the Revision para stuff Assert.AreEqual((paraRev != null) ? paraRev.Hvo : 0, subDiff.HvoRev); Assert.AreEqual(ichMinRev, subDiff.IchMinRev); Assert.AreEqual(ichLimRev, subDiff.IchLimRev); // section stuff should be null Assert.IsNull(subDiff.HvosSectionsRev); Assert.IsNull(subDiff.HvosSectionsCurr); // subDiffs may not have subDiffs, so far Assert.IsNull(subDiff.SubDiffsForORCs); Assert.IsNull(subDiff.SubDiffsForParas); Assert.AreEqual(subDiffType, subDiff.DiffType); if ((rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0) { // check the subDiff for consistency with the root diff. Assert.IsTrue((subDiff.DiffType & DifferenceType.TextDifference) != 0 || (subDiff.DiffType & DifferenceType.FootnoteAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteDifference) != 0 || (subDiff.DiffType & DifferenceType.MultipleCharStyleDifferences) != 0 || (subDiff.DiffType & DifferenceType.CharStyleDifference) != 0 || (subDiff.DiffType & DifferenceType.PictureAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureDifference) != 0 || subDiff.DiffType == DifferenceType.NoDifference, // (structure change only) subDiff.DiffType.ToString() + " is not a consistent subtype with split or merged paragraph differences."); } else { Assert.IsNotNull(paraCurr, "The current paragraph cannot be null except for para split/merge root diff"); Assert.IsNotNull(paraRev, "The revision paragraph cannot be null except for para split/merge root diff"); //check the root difference for consistency with this subDiff if (subDiff.DiffType == DifferenceType.VerseMoved) // || // subDiff.DiffType == DifferenceType.ParagraphMoved) { // this subDiff verse or paragraph was moved into an added section Assert.IsTrue(rootDiff.DiffType == DifferenceType.SectionAddedToCurrent || rootDiff.DiffType == DifferenceType.SectionMissingInCurrent, "inconsistent type of root difference"); } else if (subDiff.DiffType == DifferenceType.TextDifference) { // this subDiff text difference is within a footnote Assert.AreEqual(DifferenceType.FootnoteDifference, rootDiff.DiffType); } else Assert.Fail("unexpected type of sub-diff"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns whether or not the specified difference is a big enough change to require /// saving the entire difference list for undo/redo to work correctly. /// </summary> /// ------------------------------------------------------------------------------------ private bool IsMajorDifference(DifferenceType diffType) { return ((diffType & DifferenceType.VerseMoved) != 0 || (diffType & DifferenceType.ParagraphAddedToCurrent) != 0 || (diffType & DifferenceType.ParagraphMissingInCurrent) != 0 || (diffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (diffType & DifferenceType.ParagraphMergedInCurrent) != 0 || (diffType & DifferenceType.ParagraphStructureChange) != 0 || (diffType & DifferenceType.SectionHeadAddedToCurrent) != 0 || (diffType & DifferenceType.SectionHeadMissingInCurrent) != 0 || (diffType & DifferenceType.SectionAddedToCurrent) != 0 || (diffType & DifferenceType.SectionMissingInCurrent) != 0); }
private void DifferenceFound(DifferenceType differenceType, DiffResult result) { DifferenceFound(new Difference(differenceType), result); }