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

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

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

            editor.Comment = "b";
            Assert.AreEqual("a", d ["comment"].ToString(), "#1");
        }
예제 #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");
        }
예제 #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");
        }
예제 #6
0
        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");
        }
예제 #7
0
        public void EditProtectedProperty_NotAllowed()
        {
            var editor = new TorrentEditor(new BEncodedDictionary())
            {
                CanEditSecureMetadata = false
            };

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

            editor.SetCustom("info", new BEncodedDictionary());
        }
예제 #9
0
 //[ExpectedException (typeof (InvalidOperationException))]
 public void EditProtectedProperty_NotAllowed()
 {
     Assert.Catch <InvalidOperationException>(() => {
         var editor = new TorrentEditor(new BEncodedDictionary())
         {
             CanEditSecureMetadata = false
         };
         editor.PieceLength = 16;
     });
 }
예제 #10
0
 //[ExpectedException (typeof (InvalidOperationException))]
 public void ReplaceInfoDict()
 {
     Assert.Catch <InvalidOperationException>(() => {
         var editor = new TorrentEditor(new BEncodedDictionary())
         {
             CanEditSecureMetadata = false
         };
         editor.SetCustom("info", new BEncodedDictionary());
     });
 }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }