Exemple #1
0
        public void EditProtectedProperty_NotAllowed()
        {
            var editor = new TorrentEditor(new BEncodedDictionary());

            Assert.IsFalse(editor.CanEditSecureMetadata);
            Assert.Throws <InvalidOperationException> (() => editor.PieceLength = 16);
        }
Exemple #2
0
        public void ReplaceInfoDict()
        {
            var editor = new TorrentEditor(new BEncodedDictionary());

            Assert.IsFalse(editor.CanEditSecureMetadata);
            Assert.Throws <InvalidOperationException> (() => editor.SetCustom("info", new BEncodedDictionary()));
        }
        public void EditingCreatesCopy()
        {
            var d      = Create("comment", "a");
            var editor = new TorrentEditor(d);

            editor.Comment = "b";
            Assert.AreEqual("a", d ["comment"].ToString(), "#1");
        }
Exemple #4
0
        public void Announces_None()
        {
            var editor = new TorrentEditor(new BEncodedDictionary());
            var result = editor.ToDictionary();

            Assert.IsFalse(result.ContainsKey("announce"), "#1");
            Assert.IsFalse(result.ContainsKey("announce-list"), "#2");
        }
Exemple #5
0
        public void EditingCreatesCopy()
        {
            BEncodedDictionary d      = Create("comment", "a");
            TorrentEditor      editor = new TorrentEditor(d);

            editor.Comment = "b";
            Assert.AreEqual("a", d["comment"].ToString(), "#1");
        }
        public void EditComment()
        {
            var d      = Create("comment", "a");
            var editor = new TorrentEditor(d);

            editor.Comment = "b";
            d = editor.ToDictionary();
            Assert.AreEqual("b", d ["comment"].ToString(), "#1");
        }
Exemple #7
0
        public void EditProtectedProperty_NotAllowed()
        {
            var editor = new TorrentEditor(new BEncodedDictionary())
            {
                CanEditSecureMetadata = false
            };

            editor.PieceLength = 16;
        }
Exemple #8
0
        public void ReplaceInfoDict()
        {
            var editor = new TorrentEditor(new BEncodedDictionary())
            {
                CanEditSecureMetadata = false
            };

            editor.SetCustom("info", new BEncodedDictionary());
        }
Exemple #9
0
 //[ExpectedException (typeof (InvalidOperationException))]
 public void EditProtectedProperty_NotAllowed()
 {
     Assert.Catch <InvalidOperationException>(() => {
         var editor = new TorrentEditor(new BEncodedDictionary())
         {
             CanEditSecureMetadata = false
         };
         editor.PieceLength = 16;
     });
 }
Exemple #10
0
 //[ExpectedException (typeof (InvalidOperationException))]
 public void ReplaceInfoDict()
 {
     Assert.Catch <InvalidOperationException>(() => {
         var editor = new TorrentEditor(new BEncodedDictionary())
         {
             CanEditSecureMetadata = false
         };
         editor.SetCustom("info", new BEncodedDictionary());
     });
 }
Exemple #11
0
        public void Announces_Single()
        {
            var editor = new TorrentEditor(new BEncodedDictionary())
            {
                Announce = "udp://test.com/announce"
            };
            var result = editor.ToDictionary();

            Assert.IsTrue(result.ContainsKey("announce"), "#1");
            Assert.IsFalse(result.ContainsKey("announce-list"), "#2");
        }
Exemple #12
0
        public void EditComment_null()
        {
            var d      = Create("comment", "a");
            var editor = new TorrentEditor(d)
            {
                Comment = null
            };

            d = editor.ToDictionary();
            Assert.IsFalse(d.ContainsKey("comment"), "#1");
            Assert.IsNull(editor.Comment, "#2");
        }
Exemple #13
0
        public void Announces_OneTier()
        {
            var tier = new RawTrackerTier {
                "http://test.com/announce"
            };
            var editor = new TorrentEditor(new BEncodedDictionary());

            editor.Announces.Add(tier);

            var result = editor.ToDictionary();

            Assert.IsFalse(result.ContainsKey("announce"), "#1");
            Assert.IsTrue(result.ContainsKey("announce-list"), "#2");
        }
Exemple #14
0
        public void Announces_OneTierThenRemove()
        {
            var tier = new List <string> {
                "http://test.com/announce"
            };
            var editor = new TorrentEditor(new BEncodedDictionary());

            editor.Announces.Add(tier);

            editor = new TorrentEditor(editor.ToDictionary());
            editor.Announces.Clear();

            var result = editor.ToDictionary();

            Assert.IsFalse(result.ContainsKey("announce"), "#1");
            Assert.IsFalse(result.ContainsKey("announce-list"), "#2");
        }