示例#1
0
 public void ProcessThenWrite(MARCProcess process, MARCReader records)
 {
     foreach (MARCRecord record in records)
     {
         ProcessThenWrite(process, record);
     }
 }
示例#2
0
        public void MediumNumberOfRecords()
        {
            string toWriteFile = "mediumrecords.dat";
            string source = @"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc";
            MARCReader ourHumbleReader = new MARCReader(source);
                MARCWriter writer = new MARCWriter(toWriteFile);
                foreach(MARCRecord record in ourHumbleReader)
                {
                    writer.Write(record);
                }
                writer.Close();
                StreamReader answer = new StreamReader(source,Encoding.Default);
                StreamReader result = new StreamReader(toWriteFile);
                char[] answerBuffer = new char[1];
                char[] resultBuffer = new char[1];

                while (answer.Peek() != -1 && result.Peek() != -1)
                {
                    answer.ReadBlock(answerBuffer, 0, 1);
                    result.ReadBlock(resultBuffer, 0, 1);
                    Assert.Equals(answerBuffer[0], resultBuffer[0], ScanMessage((char)answerBuffer[0], (char)resultBuffer[0]));

                }
        
        
        
        }
示例#3
0
        public void MediumNumberOfRecords()
        {
            string     toWriteFile     = "mediumrecords.dat";
            string     source          = @"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc";
            MARCReader ourHumbleReader = new MARCReader(source);
            MARCWriter writer          = new MARCWriter(toWriteFile);

            foreach (MARCRecord record in ourHumbleReader)
            {
                writer.Write(record);
            }
            writer.Close();
            StreamReader answer = new StreamReader(source, Encoding.Default);
            StreamReader result = new StreamReader(toWriteFile);

            char[] answerBuffer = new char[1];
            char[] resultBuffer = new char[1];

            while (answer.Peek() != -1 && result.Peek() != -1)
            {
                answer.ReadBlock(answerBuffer, 0, 1);
                result.ReadBlock(resultBuffer, 0, 1);
                Assert.Equals(answerBuffer[0], resultBuffer[0], ScanMessage((char)answerBuffer[0], (char)resultBuffer[0]));
            }
        }
示例#4
0
        public void ProcessThenWrite(MARCProcess process, MARCReader records)
        {
            foreach (MARCRecord record in records)
            {
                ProcessThenWrite(process, record);
            }

        }
示例#5
0
        public void SetUp()
        {
            this.reader1 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\test.dat");
            this.writer1 = new StreamWriter(@"test1.dat");

            this.reader2 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
            this.writer2 = new StreamWriter(@"test2.dat");

            this.mkrtest = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");

            this.mnemtestFile = new StreamReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\anothertest.mrk", Encoding.Default);
            this.writerMnem   = new StreamWriter(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\Mnem.mrk");

            this.largeMARC = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
        }
示例#6
0
        public void SetUp()
        {
            this.oneRecord = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\one.dat");
            //this.oneWriter = new StreamWriter(@"singleRecord.mrc");

            this.reader1 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\test.dat");
            this.writer1 = new StreamWriter(@"test1.dat");

            this.reader2 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
            this.writer2 = new StreamWriter(@"test2.dat");

            this.mkrtest = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");

            this.largeMARC = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
        }
示例#7
0
        public void SetUp()
        {
            this.reader1 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\test.dat");
            this.writer1 = new StreamWriter(@"test1.dat");

            this.reader2 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
            this.writer2 = new StreamWriter(@"test2.dat");

            this.mkrtest = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");

            this.mnemtestFile = new StreamReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\anothertest.mrk",Encoding.Default);
            this.writerMnem = new StreamWriter(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\Mnem.mrk");

            this.largeMARC = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
        }
示例#8
0
        public void SetUp()
        {
            this.oneRecord = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\one.dat");
            //this.oneWriter = new StreamWriter(@"singleRecord.mrc");

            this.reader1 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\test.dat");
            this.writer1 = new StreamWriter(@"test1.dat");

            this.reader2 = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
            this.writer2 = new StreamWriter(@"test2.dat");

            this.mkrtest = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");

            this.largeMARC = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\part24.dat");
        }
示例#9
0
        public void ProcessThenWriteSingeRecord()
        {
            MARCWriter proctest   = new MARCWriter(@"proctest.dat");
            MARCRecord procrecord = new MARCRecord();

            proctest.ProcessThenWrite(new MARCWriter.MARCProcess(testProc), procrecord);
            proctest.Close();

            MARCReader test = new MARCReader(@"proctest.dat");

            foreach (MARCRecord record in test)
            {
                string testValue = record.GetField(999)[0].FormatField();
                Assert.Equals("hello there!", testValue);
            }
            test.Close();
        }
示例#10
0
        public void ProcessThenWriteReader()
        {
            MARCWriter proctests   = new MARCWriter(@"proctestforreader.dat");
            MARCReader procrecords = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\marc.dat");

            proctests.ProcessThenWrite(new MARCWriter.MARCProcess(testProc), procrecords);
            proctests.Close();

            MARCReader test = new MARCReader(@"proctestforreader.dat");

            foreach (MARCRecord record in test)
            {
                string testValue = record.GetField(999)[0].FormatField();
                Assert.Equals("hello there!", testValue);
            }
            test.Close();
        }
示例#11
0
        public void AnotherMultiRecordWrite()
        {
            string answer = new StreamReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrk").ReadToEnd();
            MARCBreakerWriter file = new MARCBreakerWriter("breakerMultiTest2.mrk");
            MARCReader reader = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");
            foreach (MARCRecord record in reader) { file.Write(record); }
            file.Close();
            string result = new StreamReader("breakerMultiTest2.mrk").ReadToEnd();

            //only checks that all of the characters so far are the same, not that the strings are identical
            for (int i = 0; i < answer.Length && i < result.Length; i++)
            {
                Assert.Equals(answer[i], result[i], "difference at " + i + " of " + result.Length + "\n " + (char)answer[i] + " v. " + (char)result[i]);
            }
            Assert.Equals(answer.Length, result.Length, "The answer differs by " + (answer.Length - result.Length).ToString());

        }
示例#12
0
        public void AnotherMultiRecordWrite()
        {
            string            answer = new StreamReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrk").ReadToEnd();
            MARCBreakerWriter file   = new MARCBreakerWriter("breakerMultiTest2.mrk");
            MARCReader        reader = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc");

            foreach (MARCRecord record in reader)
            {
                file.Write(record);
            }
            file.Close();
            string result = new StreamReader("breakerMultiTest2.mrk").ReadToEnd();

            //only checks that all of the characters so far are the same, not that the strings are identical
            for (int i = 0; i < answer.Length && i < result.Length; i++)
            {
                Assert.Equals(answer[i], result[i], "difference at " + i + " of " + result.Length + "\n " + (char)answer[i] + " v. " + (char)result[i]);
            }
            Assert.Equals(answer.Length, result.Length, "The answer differs by " + (answer.Length - result.Length).ToString());
        }
示例#13
0
        public void MediumNumberOfRecordsWithRecordArrays()
        {
            string     toWriteFile     = "groupsmedium.dat";
            string     source          = @"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc";
            MARCWriter groups          = new MARCWriter(toWriteFile);
            MARCReader ourHumbleReader = new MARCReader(source);

            MARCRecord[] recordGroup = new MARCRecord[5];
            int          i           = 0;

            foreach (MARCRecord record in ourHumbleReader)
            {
                if (i == 5)
                {
                    i = 0;
                    groups.Write(recordGroup);
                }
                recordGroup[i] = record;
                i++;
            }
            for (int j = 0; j < i; j++)
            {
                groups.Write(recordGroup[j]);
            }

            groups.Close();
            StreamReader answer = new StreamReader(source, Encoding.Default);
            StreamReader result = new StreamReader(toWriteFile);

            char[] answerBuffer = new char[1];
            char[] resultBuffer = new char[1];

            while (answer.Peek() != -1 && result.Peek() != -1)
            {
                answer.ReadBlock(answerBuffer, 0, 1);
                result.ReadBlock(resultBuffer, 0, 1);
                Assert.Equals(answerBuffer[0], resultBuffer[0]);
            }
        }
示例#14
0
        public void ProcessThenWriteReader()
        {
            MARCWriter proctests = new MARCWriter(@"proctestforreader.dat");
            MARCReader procrecords = new MARCReader(@"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\marc.dat");
            proctests.ProcessThenWrite(new MARCWriter.MARCProcess(testProc), procrecords);
            proctests.Close();

            MARCReader test = new MARCReader(@"proctestforreader.dat");
            foreach (MARCRecord record in test)
            {
                string testValue = record.GetField(999)[0].FormatField();
                Assert.Equals("hello there!", testValue);
            }
            test.Close();
        }
示例#15
0
 public MARCRecordEnumerator(MARCReader reader)
 {
     this.file = reader.marcStream;
 }
示例#16
0
        public void ProcessThenWriteMultipeRecords()
        {
            MARCWriter proctests = new MARCWriter(@"proctests.dat");
            MARCRecord[] procrecords = new MARCRecord[4] { new MARCRecord(), new MARCRecord(), new MARCRecord(), new MARCRecord() };
            proctests.ProcessThenWrite(new MARCWriter.MARCProcess(testProc), procrecords);
            proctests.Close();

            MARCReader test = new MARCReader(@"proctests.dat");
            foreach (MARCRecord record in test)
            {
                string testValue = record.GetField(999)[0].FormatField();
                Assert.Equals("hello there!", testValue);
            }
            test.Close();
        }
示例#17
0
        public void MediumNumberOfRecordsWithRecordArrays()
        {
            string toWriteFile = "groupsmedium.dat";
            string source = @"C:\Documents and Settings\wkurt\My Documents\Visual Studio 2008\Projects\TestMARC\TestMARC\makrtest.mrc";
            MARCWriter groups = new MARCWriter(toWriteFile);
            MARCReader ourHumbleReader = new MARCReader(source);
            MARCRecord[] recordGroup = new MARCRecord[5];
            int i = 0;
            foreach (MARCRecord record in ourHumbleReader)
            {
                if (i == 5)
                {
                    i = 0;
                    groups.Write(recordGroup);
                }
                recordGroup[i] = record;
                i++;
            }
            for (int j = 0; j < i; j++)
            { 
                groups.Write(recordGroup[j]);
            
            }

            groups.Close();
            StreamReader answer = new StreamReader(source, Encoding.Default);
            StreamReader result = new StreamReader(toWriteFile);
            char[] answerBuffer = new char[1];
            char[] resultBuffer = new char[1];

            while (answer.Peek() != -1 && result.Peek() != -1)
            {
                answer.ReadBlock(answerBuffer, 0, 1);
                result.ReadBlock(resultBuffer, 0, 1);
                Assert.Equals(answerBuffer[0], resultBuffer[0]);

            }
        }
示例#18
0
 public MARCRecordEnumerator(MARCReader reader)
 {
     this.file = reader.marcStream;
 }