Ejemplo n.º 1
0
        private string RunAlgorithmWithShift(string text, int shift)
        {
            var sb = new StringBuilder();

            foreach (var item in Split(text))
            {
                var firstLetterIndexes  = _indexHelper.GetIndexes(_key, item.FirstLetter);
                var secondLetterIndexes = _indexHelper.GetIndexes(_key, item.LastLetter);
                if (firstLetterIndexes.RowIndex == secondLetterIndexes.RowIndex)
                {
                    firstLetterIndexes.ColumnIndex  = ShiftIndex(firstLetterIndexes.ColumnIndex, shift, true);
                    secondLetterIndexes.ColumnIndex = ShiftIndex(secondLetterIndexes.ColumnIndex, shift, true);
                }
                else if (firstLetterIndexes.ColumnIndex == secondLetterIndexes.ColumnIndex)
                {
                    firstLetterIndexes.RowIndex  = ShiftIndex(firstLetterIndexes.RowIndex, shift, false);
                    secondLetterIndexes.RowIndex = ShiftIndex(secondLetterIndexes.RowIndex, shift, false);
                }
                else
                {
                    SwapRows(firstLetterIndexes, secondLetterIndexes);
                }
                sb.Append(GetCharePareByIndex(firstLetterIndexes, secondLetterIndexes).ToString());
            }
            return(sb.ToString());
        }
        public void GetRecordIndexes_MixedRecords_Works()
        {
            // Arrange,
            const string text = "[ .MANUAL_LIBRETA Manual_Libreta_TU01A.msb .VISORES [ .XYZ ( 241.0 - 248.0 0 ) .ESC EXTERIOR .CAMARA 0 ] " +
                                ".MUSICA [ .MUSICAS ( ( Battle.WAV EXTERIOR ) ( Shadows.WAV INTERIOR ) ) .MUSICA_POR_DEFECTO EXTERIOR ] .BRIEFING [ .INICIAL TU01A.BRI ]";
            var tokens = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            // Act,
            var result = IndexHelper.GetIndexes(tokens, 19);

            // Assert,
            Assert.AreEqual(19, result.nameIndex);
            Assert.AreEqual(20, result.startIndex);
            Assert.AreEqual(29, result.endIndex);
        }