public void Rename_SpaceDelimeter_CapitalizesWords() { // Arrange var name = "this is my name"; var toCamelCaseOp = new ToCamelCaseOperation(); toCamelCaseOp.DelimiterCharacters = " "; var expected = new RenameResult() { new Diff("this ", DiffOperation.Equal), new Diff("i", DiffOperation.Deletion), new Diff("I", DiffOperation.Insertion), new Diff("s ", DiffOperation.Equal), new Diff("m", DiffOperation.Deletion), new Diff("M", DiffOperation.Insertion), new Diff("y ", DiffOperation.Equal), new Diff("n", DiffOperation.Deletion), new Diff("N", DiffOperation.Insertion), new Diff("ame", DiffOperation.Equal), }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_Pascal_CapitalizesFirst() { // Arrange var name = "what a pig"; var toCamelCaseOp = new ToCamelCaseOperation(); toCamelCaseOp.UsePascal = true; toCamelCaseOp.DelimiterCharacters = " "; var expected = new RenameResult() { new Diff("w", DiffOperation.Deletion), new Diff("W", DiffOperation.Insertion), new Diff("hat ", DiffOperation.Equal), new Diff("a", DiffOperation.Deletion), new Diff("A", DiffOperation.Insertion), new Diff(" ", DiffOperation.Equal), new Diff("p", DiffOperation.Deletion), new Diff("P", DiffOperation.Insertion), new Diff("ig", DiffOperation.Equal), }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_TwoDelimitersBackToBack_SkipsBoth() { // Arrange var name = "what==a=pig"; var toCamelCaseOp = new ToCamelCaseOperation(); toCamelCaseOp.DelimiterCharacters = "="; var expected = new RenameResult() { new Diff("what==", DiffOperation.Equal), new Diff("a", DiffOperation.Deletion), new Diff("A", DiffOperation.Insertion), new Diff("=", DiffOperation.Equal), new Diff("p", DiffOperation.Deletion), new Diff("P", DiffOperation.Insertion), new Diff("ig", DiffOperation.Equal), }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_CharacterDelimiter_DelimitersArentCapitalized() { // Arrange var name = "thisxisxmyxname"; var toCamelCaseOp = new ToCamelCaseOperation(); toCamelCaseOp.DelimiterCharacters = "x"; var expected = new RenameResult() { new Diff("thisx", DiffOperation.Equal), new Diff("i", DiffOperation.Deletion), new Diff("I", DiffOperation.Insertion), new Diff("sx", DiffOperation.Equal), new Diff("m", DiffOperation.Deletion), new Diff("M", DiffOperation.Insertion), new Diff("yx", DiffOperation.Equal), new Diff("n", DiffOperation.Deletion), new Diff("N", DiffOperation.Insertion), new Diff("ame", DiffOperation.Equal), }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_EmptyString_DoesNothing() { // Arrange var name = string.Empty; var toCamelCaseOp = new ToCamelCaseOperation(); var expected = RenameResult.Empty; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_NullTarget_DoesNothing() { // Arrange string name = null; var toCamelCaseOp = new ToCamelCaseOperation(); var expected = RenameResult.Empty; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_EmptyDelimeters_RemainsUnchanged() { // Arrange var name = "whats in a name"; var toCamelCaseOp = new ToCamelCaseOperation(); toCamelCaseOp.DelimiterCharacters = string.Empty; var expected = new RenameResult() { new Diff(name, DiffOperation.Equal) }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_DashDelimeterIsEscaped_OnlyMatchesSpace() { // Arrange var name = "GameObject"; var toCamelCaseOp = new ToCamelCaseOperation(); // Dash is a special character in regex, would meaning to use "space' through "Underscore" if // not properly escaped. toCamelCaseOp.DelimiterCharacters = " -_"; var expected = new RenameResult() { new Diff("G", DiffOperation.Deletion), new Diff("g", DiffOperation.Insertion), new Diff("ameObject", DiffOperation.Equal), }; // Act var result = toCamelCaseOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
/// <summary> /// Initializes a new instance of the <see cref="ToCamelCaseOperation"/> class by copying another. /// </summary> /// <param name="operationToCopy">Operation to copy.</param> public ToCamelCaseOperation(ToCamelCaseOperation operationToCopy) { this.delimiterCharacters = operationToCopy.delimiterCharacters; this.usePascal = operationToCopy.usePascal; }
/// <summary> /// Clone this instance. /// </summary> /// <returns>A clone of this instance</returns> public IRenameOperation Clone() { var clone = new ToCamelCaseOperation(this); return(clone); }