コード例 #1
0
        public void GetOrdinal_returns_lowest_ordinal_if_same_name_appears_more_than_once()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection<string>(new List<string> { "A", "B", "B", "A" }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
        }
コード例 #2
0
        public void Lookup_can_be_built_from_collection()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection<string>(new List<string> { "A", "B", "C" }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
            Assert.Equal(2, lookup.GetOrdinal("C"));
        }
コード例 #3
0
        public void GetOrdinal_throws_if_name_is_not_found()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection<string>(new List<string> { "A", "a", "b", "ゕ" }));

            Assert.Equal(
                "ヶ",
                Assert.Throws<IndexOutOfRangeException>(() => lookup.GetOrdinal("ヶ")).Message);
        }
コード例 #4
0
        public void GetOrdinal_uses_case_sensitive_then_insensitive_then_ignores_kana()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection<string>(new List<string> { "A", "a", "b", "ゕ" }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("a"));
            Assert.Equal(2, lookup.GetOrdinal("B"));
            Assert.Equal(3, lookup.GetOrdinal("ヵ"));
        }
コード例 #5
0
        public void GetOrdinal_returns_lowest_ordinal_if_same_name_appears_more_than_once()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection <string>(new List <string> {
                "A", "B", "B", "A"
            }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
        }
コード例 #6
0
        public void GetOrdinal_throws_if_name_is_not_found()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection <string>(new List <string> {
                "A", "a", "b", "ゕ"
            }));

            Assert.Equal(
                "ヶ",
                Assert.Throws <IndexOutOfRangeException>(() => lookup.GetOrdinal("ヶ")).Message);
        }
コード例 #7
0
        public void Lookup_can_be_built_from_collection()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection <string>(new List <string> {
                "A", "B", "C"
            }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
            Assert.Equal(2, lookup.GetOrdinal("C"));
        }
コード例 #8
0
        public void GetOrdinal_uses_case_sensitive_then_insensitive_then_ignores_kana()
        {
            var lookup = new FieldNameLookup(new ReadOnlyCollection <string>(new List <string> {
                "A", "a", "b", "ゕ"
            }));

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("a"));
            Assert.Equal(2, lookup.GetOrdinal("B"));
            Assert.Equal(3, lookup.GetOrdinal("ヵ"));
        }
コード例 #9
0
        public void Lookup_can_be_built_from_reader()
        {
            var mockDataRecord = new Mock<IDataRecord>();
            mockDataRecord.Setup(m => m.FieldCount).Returns(3);
            mockDataRecord.Setup(m => m.GetName(0)).Returns("A");
            mockDataRecord.Setup(m => m.GetName(1)).Returns("B");
            mockDataRecord.Setup(m => m.GetName(2)).Returns("C");

            var lookup = new FieldNameLookup(mockDataRecord.Object);

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
            Assert.Equal(2, lookup.GetOrdinal("C"));
        }
コード例 #10
0
        public void Lookup_can_be_built_from_reader()
        {
            var mockDataRecord = new Mock <IDataRecord>();

            mockDataRecord.Setup(m => m.FieldCount).Returns(3);
            mockDataRecord.Setup(m => m.GetName(0)).Returns("A");
            mockDataRecord.Setup(m => m.GetName(1)).Returns("B");
            mockDataRecord.Setup(m => m.GetName(2)).Returns("C");

            var lookup = new FieldNameLookup(mockDataRecord.Object);

            Assert.Equal(0, lookup.GetOrdinal("A"));
            Assert.Equal(1, lookup.GetOrdinal("B"));
            Assert.Equal(2, lookup.GetOrdinal("C"));
        }