Ejemplo n.º 1
0
 public void ProcessThenWrite(MARCProcess process, MARCReader records)
 {
     foreach (MARCRecord record in records)
     {
         ProcessThenWrite(process, record);
     }
 }
Ejemplo n.º 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]));

                }
        
        
        
        }
Ejemplo n.º 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]));
            }
        }
Ejemplo n.º 4
0
        public void ProcessThenWrite(MARCProcess process, MARCReader records)
        {
            foreach (MARCRecord record in records)
            {
                ProcessThenWrite(process, record);
            }

        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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());

        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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]);
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 15
0
 public MARCRecordEnumerator(MARCReader reader)
 {
     this.file = reader.marcStream;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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]);

            }
        }
Ejemplo n.º 18
0
 public MARCRecordEnumerator(MARCReader reader)
 {
     this.file = reader.marcStream;
 }