Ejemplo n.º 1
0
        public void ReadSection_IfContentEmpty_ReturnsEmptyResult()
        {
            using (var stream = new MemoryStream())
                using (var reader = new KeyPairFileReader(stream, _encoding))
                {
                    var section = reader.ReadSection();

                    Assert.Empty(section);
                }
        }
Ejemplo n.º 2
0
        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);
                }
        }
Ejemplo n.º 3
0
        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);
                }
        }