Esempio n. 1
0
        public void CanEncode_EmptyList()
        {
            var blist   = new BList();
            var bencode = blist.EncodeAsString();

            bencode.Should().Be("le");
        }
Esempio n. 2
0
        public void CanEncode_Complex()
        {
            var blist = new BList
            {
                "spam",
                666,
                new BList
                {
                    "foo",
                    "bar",
                    123,
                    new BDictionary
                    {
                        { "more spam", "more eggs" }
                    }
                },
                "foobar",
                new BDictionary
                {
                    { "numbers", new BList {
                          1, 2, 3
                      } }
                }
            };

            var bencode = blist.EncodeAsString();

            bencode.Should().Be("l4:spami666el3:foo3:bari123ed9:more spam9:more eggsee6:foobard7:numbersli1ei2ei3eeee");
        }
Esempio n. 3
0
        public void CanEncode_Simple()
        {
            var blist = new BList {
                "hello world", 987, "foobar"
            };
            var bencode = blist.EncodeAsString();

            bencode.Should().Be("l11:hello worldi987e6:foobare");
        }
Esempio n. 4
0
        public void CanEncode_UTF8()
        {
            var blist = new BList {
                "æøå äö èéê ñ"
            };
            var bencode = blist.EncodeAsString();

            bencode.Should().Be("l21:æøå äö èéê ñe");
        }
Esempio n. 5
0
        public void CanEncode_ISO88591()
        {
            var encoding = Encoding.GetEncoding("ISO-8859-1");
            var blist    = new BList {
                new BString("æøå äö èéê ñ", encoding)
            };

            var bencode = blist.EncodeAsString(encoding);

            bencode.Should().Be("l12:æøå äö èéê ñe");
        }