Ejemplo n.º 1
0
        public void EncodeBinary_ShouldEncodeCorrectly(string msg, params int[] expected)
        {
            // Act
            IEnumerable <int> result = HighLevelEncoding.EncodeBinary(msg, HighLevelEncoding.EncodingMode.Text);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 2
0
        public void Encode_ShouldEncodeCorrectly(string msg, params int[] expected)
        {
            // Act
            int[] result = HighLevelEncoding.Encode(msg);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 3
0
        public void Encode_Binary_ShouldEncodeCorrectly(int contentLength, int expectedLength)
        {
            // Arrange
            byte[] data = Enumerable.Range(0, contentLength).Select(i => (byte)(128 + (i % 30))).ToArray();

            // Act
            BitList result = HighLevelEncoding.Encode(data);

            // Assert
            result.Length.Should().Be(expectedLength);
        }
Ejemplo n.º 4
0
        public void Encode_MixedBinary_ShouldEncodeCorrectly(string content, string expectedBitPattern)
        {
            // Arrange
            expectedBitPattern = expectedBitPattern.Replace(" ", string.Empty);
            byte[] data = content.Select(x => (byte)x).ToArray();

            // Act
            BitList result = HighLevelEncoding.Encode(data);

            // Assert
            result.ToString().Should().Be(expectedBitPattern);
        }
Ejemplo n.º 5
0
        public void Encode_Binary_PrecededByLowerCaseChar_ShouldEncodeCorrectly(int contentLength, int expectedLength)
        {
            // Arrange
            byte[] data = new[] { (byte)'a' }
            .Concat(Enumerable.Range(0, contentLength - 1).Select(i => (byte)(128 + (i % 30))))
            .ToArray();

            // Act
            BitList result = HighLevelEncoding.Encode(data);

            // Assert
            result.Length.Should().Be(expectedLength);
        }
Ejemplo n.º 6
0
        public void Encode_ShouldKeepBitCountLow()
        {
            // Found on an airline boarding pass.  Several stretches of Binary shift are
            // necessary to keep the bit-count so low.

            // Arrange
            const string content = "09  UAG    ^160MEUCIQC0sYS/HpKxnBELR1uB85R20OoqqwFGa0q2uEiYgh6utAIgLl1aBVM4EOTQtMQQYH9M2Z3Dp4qnA/fwWuQ+M8L3V8U=";

            byte[] data = content.Select(x => (byte)x).ToArray();

            // Act
            BitList result = HighLevelEncoding.Encode(data);

            // Assert
            result.Length.Should().Be(823);
        }