Exemplo n.º 1
0
        public void RemoveAtTest()
        {
            var document = new CsvDocument(new string[] { "name", "age" });

            document.Write("Light", 18);
            document.Write("Misa", 20);

            document.RemoveAt(0);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                document.RemoveAt(-1);
            });

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                document.RemoveAt(1);
            });

            Assert.IsFalse(document.IsEmpty);
            Assert.AreEqual(1, document.Count);
        }
Exemplo n.º 2
0
        public void RemoveAtTest()
        {
            var document = new CsvDocument <Person>(new Person[]
            {
                new Person {
                    Name = "Akari", Age = 20
                },
                new Person {
                    Name = "Kyoko", Age = 21
                },
                new Person {
                    Name = "Yui", Age = 22
                },
                new Person {
                    Name = "Chinatsu", Age = 19
                }
            });

            Assert.AreEqual(4, document.Count);

            document.RemoveAt(0);

            Assert.AreEqual(3, document.Count);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                document.RemoveAt(3);
            });

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                document.RemoveAt(-1);
            });

            Assert.AreEqual(new CsvRecord(document.Header, new string[] { "Kyoko", "21" }), document[0]);
            Assert.AreEqual(new CsvRecord(document.Header, new string[] { "Yui", "22" }), document[1]);
            Assert.AreEqual(new CsvRecord(document.Header, new string[] { "Chinatsu", "19" }), document[2]);
        }