예제 #1
0
 public void SetAddressArray(string[] value)
 {
     fLines.Clear();
     fLines.AddRange(value);
 }
예제 #2
0
        public void Test_Common()
        {
            string[] list = new string[] { "The", "string", "list", "test" };

            var strList0 = new GDMLines();

            strList0.Text = "The string list test";
            Assert.AreEqual("The string list test", strList0.Text);

            GDMLines strList = new GDMLines(list);

            Assert.AreEqual("The", strList[0]);
            Assert.AreEqual("string", strList[1]);
            Assert.AreEqual("list", strList[2]);
            Assert.AreEqual("test", strList[3]);

            Assert.AreEqual(0, strList.IndexOf("The"));
            Assert.AreEqual(1, strList.IndexOf("string"));
            Assert.AreEqual(2, strList.IndexOf("list"));
            Assert.AreEqual(3, strList.IndexOf("test"));
            Assert.AreEqual(-1, strList.IndexOf("abrakadabra"));

            Assert.AreEqual("The\r\nstring\r\nlist\r\ntest", strList.Text);

            var strList1 = new GDMLines("The\r\nstring\r\nlist\r\ntest");

            Assert.AreEqual("The", strList1[0]);
            Assert.AreEqual("string", strList1[1]);
            Assert.AreEqual("list", strList1[2]);
            Assert.AreEqual("test", strList1[3]);

            GDMLines strList2 = new GDMLines();

            strList2.Assign(null);
            strList2.Assign(strList);
            Assert.AreEqual("The", strList2[0]);
            Assert.AreEqual("string", strList2[1]);
            Assert.AreEqual("list", strList2[2]);
            Assert.AreEqual("test", strList2[3]);
            strList2.Clear();

            GDMLines otherList = null;

            Assert.Throws(typeof(ArgumentNullException), () => { strList2.AddRange(otherList); });

            strList2.AddRange(strList);
            Assert.AreEqual("The", strList2[0]);
            Assert.AreEqual("string", strList2[1]);
            Assert.AreEqual("list", strList2[2]);
            Assert.AreEqual("test", strList2[3]);
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList2.RemoveAt(-1); });

            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { object item = strList2[-1]; });
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList2[-1] = null; });

            string[] listVals = strList.ToArray();
            Assert.AreEqual("The", listVals[0]);
            Assert.AreEqual("string", listVals[1]);
            Assert.AreEqual("list", listVals[2]);
            Assert.AreEqual("test", listVals[3]);

            strList[2] = "string2";
            Assert.AreEqual("string2", strList[2]);

            strList.Insert(0, "insert test");
            Assert.AreEqual("insert test", strList[0]);
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList.Insert(-1, "insert test2"); }); // List index out of bounds

            strList.Clear();
            Assert.IsTrue(strList.IsEmpty());

            string[] strArr = null;
            Assert.Throws(typeof(ArgumentNullException), () => { strList.AddRange(strArr); });
        }
예제 #3
0
 public void SetNotesArray(params string[] value)
 {
     fLines.Clear();
     fLines.AddRange(value);
 }