public void CharacterStringWithWrongLengthUnder() { var fixture = new byte[] { 0x01, (byte)'f', (byte)'o' }; var result = CharacterString.FromArray(fixture, 0, out var endOffset); Assert.Equal(2, result.Size); Assert.Equal("f", result.ToString()); Assert.Equal(2, endOffset); }
public void EmptyCharacterString() { int endOffset = 0; byte[] content = Helper.ReadFixture("CharacterString", "empty-string"); CharacterString characterString = CharacterString.FromArray(content, 0, out endOffset); Assert.Equal("", characterString.ToString()); Assert.Equal(1, characterString.Size); Assert.Equal(1, endOffset); }
public void SimpleCharacterString() { int endOffset = 0; byte[] content = Helper.ReadFixture("CharacterString", "www-string"); CharacterString characterString = CharacterString.FromArray(content, 0, out endOffset); Assert.Equal("www", characterString.ToString()); Assert.Equal(4, characterString.Size); Assert.Equal(4, endOffset); }
public void CharacterStringWithEmptyData() { var fixture = new byte[] {}; Assert.Throws <ArgumentException>(() => CharacterString.FromArray(fixture, 0)); }
public void CharacterStringWithWrongOffset() { var fixture = new byte[] { 0x03, (byte)'f', (byte)'o', (byte)'o' }; Assert.Throws <IndexOutOfRangeException>(() => CharacterString.FromArray(fixture, 4)); }
public void CharacterStringWithWrongLengthOver() { var fixture = new byte[] { 0x03, (byte)'f', (byte)'o' }; Assert.Throws <ArgumentException>(() => CharacterString.FromArray(fixture, 0)); }