public void Encode_ShouldEncodeCorrectly(string msg, params int[] expected) { // Act int[] result = HighLevelEncoding.Encode(msg); // Assert result.Should().BeEquivalentTo(expected); }
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); }
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); }
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); }
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); }