Ejemplo n.º 1
0
        public void Title()
        {
            int tag = 245;

            string[] indicators1 = new string[2] {
                "0", "1"
            };
            List <string> subfields1 = new List <string> {
                "a", "Foo :", "b", "bar"
            };
            MARCField  field1  = new MARCField(tag, indicators1, subfields1);
            MARCRecord record1 = new MARCRecord();

            record1.AddField(field1);

            Assert.Equals("Foo :bar", record1.Title);

            string[] indicators2 = new string[2] {
                "0", "1"
            };
            List <string> subfields2 = new List <string> {
                "a", "Farghin"
            };
            MARCField  field2  = new MARCField(tag, indicators2, subfields2);
            MARCRecord record2 = new MARCRecord();

            record2.AddField(field2);

            Assert.Equals("Farghin", record2.Title);
        }
Ejemplo n.º 2
0
 private MARCRecord testProc(MARCRecord record)
 {
     record.AddField(new MARCField(999, new string[2] {
         "", ""
     }, new List <string> {
         "a", "hello there!"
     }));
     return(record);
 }
Ejemplo n.º 3
0
        public void SortFields()
        {
            MARCRecord messyRecord = new MARCRecord();

            messyRecord.AddField(new MARCField(999
                                               , new string[2] {
                "1", "0"
            }
                                               , new List <string> {
                "a", "stuff"
            }));
            messyRecord.AddField(new MARCField(645
                                               , new string[2] {
                "1", "0"
            }
                                               , new List <string> {
                "b", "more stuff"
            }));
            messyRecord.AddField(new MARCField(1
                                               , new string[2] {
                "1", "0"
            }
                                               , new List <string> {
                "c", "zmore stuff"
            }));
            messyRecord.AddField(new MARCField(997
                                               , new string[2] {
                "1", "0"
            }
                                               , new List <string> {
                "d", "stuffs stuff"
            }));

            messyRecord.SortFields();
            MARCField[] sortedFields = messyRecord.Fields.ToArray();
            for (int i = 0; i < sortedFields.Length - 1; i++)
            {
                Assert.True(Int32.Parse(sortedFields[i].tag) < Int32.Parse(sortedFields[i + 1].tag));
            }
        }
Ejemplo n.º 4
0
        public void AddField()
        {
            int tag = 245;

            string[] indicators = new string[2] {
                "1", "0"
            };
            List <string> subfields = new List <string> {
                "a", "Python", "c", "Guido"
            };
            MARCField  newField = new MARCField(tag, indicators, subfields, "");
            MARCRecord record   = new MARCRecord();

            record.AddField(newField);
            Assert.Contains(newField, record.Fields);
        }
Ejemplo n.º 5
0
        public void Author()
        {
            int tag = 100;

            string[]      indicators = new string[] { "1", "0" };
            List <string> subfields  = new List <string> {
                "a", "Bletch, Foobie,", "d", "1979-1981."
            };
            MARCField  field  = new MARCField(tag, indicators, subfields);
            MARCRecord record = new MARCRecord();

            record.AddField(field);
            Assert.Equals("Bletch, Foobie, 1979-1981.", record.Author);

            MARCRecord blankRecord = new MARCRecord();

            Assert.Null(blankRecord.Author);
        }
Ejemplo n.º 6
0
        public void ISBN()
        {
            int tag = 20;

            string[]      indicators = new string[] { "0", "1" };
            List <string> subfields  = new List <string> {
                "a", "123456789"
            };
            MARCRecord record = new MARCRecord();
            MARCField  field  = new MARCField(tag, indicators, subfields);

            record.AddField(field);
            Assert.Equals("123456789", record.ISBN);

            MARCRecord blankRecord = new MARCRecord();

            Assert.Null(blankRecord.ISBN);
        }
Ejemplo n.º 7
0
        public void MapField()
        {
            //test the case of 1:1 mapping
            int tag = 245;

            string[] indicators = new string[2] {
                "1", "0"
            };
            List <string> subfields = new List <string> {
                "a", "Python", "c", "Guido"
            };
            MARCField  newField = new MARCField(tag, indicators, subfields, "");
            MARCRecord record   = new MARCRecord();

            record.AddField(newField);
            record.MapField(245, 300);
            Assert.Equals(0, record.GetField(245).Length);
            Assert.Equals(1, record.GetField(300).Length);
        }
Ejemplo n.º 8
0
        public void HasField()
        {
            int tag = 245;

            string[] indicators = new string[2] {
                "1", "0"
            };
            List <string> subfields = new List <string> {
                "a", "Python", "c", "Guido"
            };
            MARCField  newField = new MARCField(tag, indicators, subfields, "");
            MARCRecord record   = new MARCRecord();

            record.AddField(newField);
            Assert.True(record.HasField(245));
            Assert.False(record.HasField(300));

            //test after a map
            record.MapField(245, 300);
            Assert.True(record.HasField(300));
            Assert.False(record.HasField(245));
        }