public void ReadSection_IfContentEmpty_ReturnsEmptyResult() { using (var stream = new MemoryStream()) using (var reader = new KeyPairFileReader(stream, _encoding)) { var section = reader.ReadSection(); Assert.Empty(section); } }
public void ReadSection_IfSectionIsNotNewLineTerminated_Throws(string content) { var bytes = Encoding.UTF8.GetBytes(content); using (var stream = new MemoryStream(bytes)) using (var reader = new KeyPairFileReader(stream, _encoding)) { var exception = Assert.Throws <SignatureException>(() => reader.ReadSection()); Assert.Equal("The package signature content is invalid.", exception.Message); } }
public void ReadSection_ReadsMultipleSections() { var bytes = Encoding.UTF8.GetBytes("a:b\r\n\r\nc:d\r\n\r\n"); using (var stream = new MemoryStream(bytes)) using (var reader = new KeyPairFileReader(stream, _encoding)) { var headerSection = reader.ReadSection(); Assert.Equal(1, headerSection.Count); Assert.Equal("b", headerSection["a"]); var section = reader.ReadSection(); Assert.Equal(1, section.Count); Assert.Equal("d", section["c"]); section = reader.ReadSection(); Assert.Empty(section); } }