Esempio n. 1
0
        public void RenameToLower_ValidUpperCharacters_AreLowered()
        {
            // Arrange
            var name         = "SOME UPPER";
            var changeCaseOp = new ChangeCaseOperation();

            var expectedName = "some upper";
            var expected     = new RenameResult();

            for (int i = 0; i < name.Length; ++i)
            {
                var expectedNameChar = expectedName.Substring(i, 1);
                var nameChar         = name.Substring(i, 1);
                if (nameChar == expectedNameChar)
                {
                    expected.Add(new Diff(nameChar, DiffOperation.Equal));
                    continue;
                }

                expected.Add(new Diff(nameChar, DiffOperation.Deletion));
                expected.Add(new Diff(expectedNameChar, DiffOperation.Insertion));
            }

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        public void RenameToUpper_ValidLowerCharacters_AreUppered()
        {
            // Arrange
            var name         = "this is all lower";
            var changeCaseOp = new ChangeCaseOperation();

            changeCaseOp.Casing = ChangeCaseOperation.CasingChange.Uppercase;

            var expectedName = "THIS IS ALL LOWER";
            var expected     = new RenameResult();

            for (int i = 0; i < name.Length; ++i)
            {
                var expectedNameChar = expectedName.Substring(i, 1);
                var nameChar         = name.Substring(i, 1);
                if (nameChar == expectedNameChar)
                {
                    expected.Add(new Diff(nameChar, DiffOperation.Equal));
                    continue;
                }

                expected.Add(new Diff(nameChar, DiffOperation.Deletion));
                expected.Add(new Diff(expectedNameChar, DiffOperation.Insertion));
            }

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 3
0
        public void Rename_EmptyString_DoesNothing()
        {
            // Arrange
            var name         = string.Empty;
            var changeCaseOp = new ChangeCaseOperation();

            var expected = RenameResult.Empty;

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 4
0
        public void Rename_NullTarget_DoesNothing()
        {
            // Arrange
            string name         = null;
            var    changeCaseOp = new ChangeCaseOperation();

            var expected = RenameResult.Empty;

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 5
0
        public void Rename_Symbols_AreUnchanged()
        {
            // Arrange
            var name         = "!@#$%^&*()_-=+[]\\;',.";
            var changeCaseOp = new ChangeCaseOperation();

            var expected = new RenameResult()
            {
                new Diff(name, DiffOperation.Equal)
            };

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 6
0
        public void RenameToLower_ValidUpperCharactersFirstOnly_OnlyFirstLowered()
        {
            // Arrange
            var name         = "SOME Upper";
            var changeCaseOp = new ChangeCaseOperation();

            changeCaseOp.ChangeFirstCharacterOnly = true;

            var expected = new RenameResult()
            {
                new Diff("S", DiffOperation.Deletion),
                new Diff("s", DiffOperation.Insertion),
                new Diff("OME Upper", DiffOperation.Equal),
            };

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 7
0
        public void RenameToUpper_ValidLowerCharactersFirstOnly_OnlyFirstIsUppered()
        {
            // Arrange
            var name         = "this is ALMOST all lower";
            var changeCaseOp = new ChangeCaseOperation();

            changeCaseOp.Casing = ChangeCaseOperation.CasingChange.Uppercase;
            changeCaseOp.ChangeFirstCharacterOnly = true;

            var expected = new RenameResult()
            {
                new Diff("t", DiffOperation.Deletion),
                new Diff("T", DiffOperation.Insertion),
                new Diff("his is ALMOST all lower", DiffOperation.Equal),
            };

            // Act
            var result = changeCaseOp.Rename(name, 0);

            // Assert
            Assert.AreEqual(expected, result);
        }