Пример #1
0
        public void GetValueTest()
        {
            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(new Person {
                Name = "Akari", Age = 20
            }, document.GetValue(0));
            Assert.AreEqual(new Person {
                Name = "Kyoko", Age = 21
            }, document.GetValue(1));
            Assert.AreEqual(new Person {
                Name = "Yui", Age = 22
            }, document.GetValue(2));
            Assert.AreEqual(new Person {
                Name = "Chinatsu", Age = 19
            }, document.GetValue(3));

            Assert.Throws <IndexOutOfRangeException>(() =>
            {
                var _ = document.GetValue(-1);
            });
        }