public void Rename_NullTarget_ReturnsEmpty() { // Arrange string name = null; var renameOp = new AdjustNumberingOperation(); var expected = RenameResult.Empty; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_EmptySequence_AddsNothing() { // Arrange string name = "Blah"; var renameOp = new AdjustNumberingOperation(); var expected = new RenameResult() { new Diff("Blah", DiffOperation.Equal) }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_OnlyNumbersZeroOffset_DoesNothing() { // Arrange var name = "123"; var renameOp = new AdjustNumberingOperation(); renameOp.Offset = 0; var expected = new RenameResult() { new Diff("123", DiffOperation.Equal), }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_BigPositiveOffset_IncreasesStringLength() { // Arrange var name = "1"; var renameOp = new AdjustNumberingOperation(); renameOp.Offset = 24; var expected = new RenameResult() { new Diff("1", DiffOperation.Deletion), new Diff("25", DiffOperation.Insertion), }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_OnlyNumbersNegativeOffset_Subtracts() { // Arrange var name = "123"; var renameOp = new AdjustNumberingOperation(); renameOp.Offset = -1; var expected = new RenameResult() { new Diff("12", DiffOperation.Equal), new Diff("3", DiffOperation.Deletion), new Diff("2", DiffOperation.Insertion), }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_BigNegativeOffset_ShortensString() { // Arrange var name = "12"; var renameOp = new AdjustNumberingOperation(); renameOp.Offset = -4; var expected = new RenameResult() { new Diff("1", DiffOperation.Deletion), new Diff("8", DiffOperation.Insertion), new Diff("2", DiffOperation.Deletion), }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }
public void Rename_MultipleNumberGroups_AddsToAll() { // Arrange var name = "234abc567"; var renameOp = new AdjustNumberingOperation(); renameOp.Offset = 1; var expected = new RenameResult() { new Diff("23", DiffOperation.Equal), new Diff("4", DiffOperation.Deletion), new Diff("5", DiffOperation.Insertion), new Diff("abc56", DiffOperation.Equal), new Diff("7", DiffOperation.Deletion), new Diff("8", DiffOperation.Insertion), }; // Act var result = renameOp.Rename(name, 0); // Assert Assert.AreEqual(expected, result); }