Exemplo n.º 1
0
        public void IsEofTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");

            Assert.IsFalse(annotator.IsEof);

            // Reading some data
            annotator.ReadNext();
            Assert.IsFalse(annotator.IsEof);

            // Reading all available annotations.
            annotator.ReadAll();
            Assert.IsTrue(annotator.IsEof);

            // Seeking to the beginning.
            annotator.Seek(Time.Zero);
            Assert.IsFalse(annotator.IsEof);

            annotator.ReadAll();
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);
            // Reopening
            annotator.Open("data/100s");
            Assert.IsFalse(annotator.IsEof);
            annotator.Close();
        }
Exemplo n.º 2
0
        public void ReadAllOpenedAnnotatorTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");
            var expectedAnnotations = new List <Annotation>();

            while (!annotator.IsEof)
            {
                expectedAnnotations.Add(annotator.ReadNext());
            }
            Assert.IsTrue(annotator.IsEof);
            annotator.Seek(Time.Zero);

            var annotations = annotator.ReadAll();

            Assert.AreEqual(expectedAnnotations, annotations);
            annotator.Close();

            // Reopening
            annotator.Open("data/100s");
            annotations = annotator.ReadAll();
            Assert.AreEqual(expectedAnnotations, annotations);
            annotator.Close();
        }
        public void CloseClosedAnnotatorTest()
        {
            var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
            annotator.Open("data/100s");
            annotator.Close();

            annotator.Close();
        }
Exemplo n.º 4
0
        public void CloseClosedAnnotatorTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");
            annotator.Close();

            annotator.Close();
        }
Exemplo n.º 5
0
        public void NumberTest()
        {
            var annotator1 = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator1.Open("data/100s");
            Assert.AreEqual(0, annotator1.Number);

            var annotator2 = new Annotator {
                Name = "hrv", Stat = Stat.Read
            };

            annotator2.Open("data/100s");
            Assert.AreEqual(0, annotator1.Number);
            Assert.AreEqual(1, annotator2.Number);

            annotator1.Close();
            Assert.AreEqual(-1, annotator1.Number);
            Assert.AreEqual(0, annotator2.Number);

            annotator1.Open("data/100s");
            Assert.AreEqual(0, annotator2.Number);
            Assert.AreEqual(1, annotator1.Number);
            Annotator.CloseAll();

            Assert.AreEqual(-1, annotator1.Number);
            Assert.AreEqual(-1, annotator2.Number);
        }
 public void IsEofClosedAnnotatorTest()
 {
     var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
     annotator.Open("data/100s");
     annotator.Close();
     var isEof = annotator.IsEof; // throws the exception.
 }
Exemplo n.º 7
0
        public void ReadNextCountTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");

            // Gets the total number of annotations available in the current annotator file.
            var availableAnnotationsCount = annotator.ReadAll().Count;

            // Reset the pointer to the first annotation.
            annotator.Seek(Time.Zero);

            // Read all using ReadNext(Count)
            var readCount = annotator.ReadNext(availableAnnotationsCount).Count;

            Assert.AreEqual(availableAnnotationsCount, readCount);
            Assert.IsTrue(annotator.IsEof);

            // Cant read when the
            readCount = annotator.ReadNext(1).Count;
            Assert.AreEqual(0, readCount);

            // Seeking to the middle of the file.
            var middle = availableAnnotationsCount / 2;

            annotator.Seek(Time.Zero);
            annotator.Seek(middle);

            readCount = annotator.ReadNext(availableAnnotationsCount).Count;
            Assert.AreEqual(availableAnnotationsCount - middle, readCount);

            Assert.IsTrue(annotator.IsEof);

            // Testing boundaries
            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(1).Count;
            Assert.AreEqual(1, readCount);

            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(availableAnnotationsCount + 1).Count;
            Assert.AreEqual(availableAnnotationsCount, readCount);

            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(int.MaxValue).Count;
            Assert.AreEqual(availableAnnotationsCount, readCount);

            // Testing invalid values.
            try
            {
                annotator.ReadNext(-1);
                Assert.Fail("ArgumentOutOfRangeException should have been thrown.");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            annotator.Close();
        }
Exemplo n.º 8
0
        public void CloseUnopenedAnnotatorTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Close();
        }
Exemplo n.º 9
0
        public void IsEofClosedAnnotatorTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");
            annotator.Close();
            var isEof = annotator.IsEof; // throws the exception.
        }
Exemplo n.º 10
0
        public void ReadAllClosedAnnotatorTest()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");
            annotator.Close();
            annotator.ReadAll().ToList(); // force a loop
        }
Exemplo n.º 11
0
 public static void UsingAnnotatorClass1()
 {
     Console.WriteLine("exgetann Using Annotator.ReadAll method");
     var annotator = new Annotator();
     annotator.Name = "atr";
     annotator.Stat = Stat.Read;
     annotator.Open("data/100s");
     foreach (var annotation in annotator.ReadAll())
     {
         Console.WriteLine(annotation.ToString());
     }
     annotator.Close();
 }
Exemplo n.º 12
0
        public static void UsingAnnotatorClass1()
        {
            Console.WriteLine("exgetann Using Annotator.ReadAll method");
            var annotator = new Annotator();

            annotator.Name = "atr";
            annotator.Stat = Stat.Read;
            annotator.Open("data/100s");
            foreach (var annotation in annotator.ReadAll())
            {
                Console.WriteLine(annotation.ToString());
            }
            annotator.Close();
        }
Exemplo n.º 13
0
        public static void UsingAnnotatorClass2()
        {
            Console.WriteLine("exgetann Using Annotator.ReadNext(int count) method, reading 50 annotation.");
            var annotator = new Annotator();
            annotator.Name = "atr";
            annotator.Stat = Stat.Read;
            annotator.Open("data/100s");

            foreach (var annotation in annotator.ReadNext(50))
            {
                Console.WriteLine(annotation.ToString());
            }

            annotator.Close();
        }
Exemplo n.º 14
0
        public void OpenClose1AnnotatorValidRecordTest()
        {
            // Valid annotator

            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };


            // ****************************
            // Keeping old annotators open.
            // ****************************

            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);

            // Reopening the same annotator.
            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);
        }
Exemplo n.º 15
0
        public static void UsingAnnotatorClass2()
        {
            Console.WriteLine("exgetann Using Annotator.ReadNext(int count) method, reading 50 annotation.");
            var annotator = new Annotator();

            annotator.Name = "atr";
            annotator.Stat = Stat.Read;
            annotator.Open("data/100s");

            foreach (var annotation in annotator.ReadNext(50))
            {
                Console.WriteLine(annotation.ToString());
            }

            annotator.Close();
        }
Exemplo n.º 16
0
        public void OpenNAnnotatorCloseOldValidRecord()
        {
            var annotator = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);

            var annotator2 = new Annotator {
                Name = "hrv", Stat = Stat.Read
            };

            annotator2.Open("data/100s", false);
            Assert.IsFalse(annotator.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            annotator2.Close();
        }
        public void NumberTest()
        {
            var annotator1 = new Annotator { Name = "atr", Stat = Stat.Read };
            annotator1.Open("data/100s");
            Assert.AreEqual(0, annotator1.Number);

            var annotator2 = new Annotator { Name = "hrv", Stat = Stat.Read };
            annotator2.Open("data/100s");
            Assert.AreEqual(0, annotator1.Number);
            Assert.AreEqual(1, annotator2.Number);

            annotator1.Close();
            Assert.AreEqual(-1, annotator1.Number);
            Assert.AreEqual(0, annotator2.Number);

            annotator1.Open("data/100s");
            Assert.AreEqual(0, annotator2.Number);
            Assert.AreEqual(1, annotator1.Number);
            Annotator.CloseAll();

            Assert.AreEqual(-1, annotator1.Number);
            Assert.AreEqual(-1, annotator2.Number);
        }
        public void OpenClose1AnnotatorValidRecordTest()
        {
            // Valid annotator

            var annotator = new Annotator { Name = "atr", Stat = Stat.Read };

            // ****************************
            // Keeping old annotators open.
            // ****************************

            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);

            // Reopening the same annotator.
            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);
        }
        public void OpenNAnnotatorCloseOldValidRecord()
        {
            var annotator = new Annotator {Name = "atr", Stat = Stat.Read};
            annotator.Open("data/100s");
            Assert.IsTrue(annotator.IsOpen);

            var annotator2 = new Annotator {Name = "hrv", Stat = Stat.Read};
            annotator2.Open("data/100s", false);
            Assert.IsFalse(annotator.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            annotator2.Close();
        }
        public void OpenNAnnotatorValidRecord()
        {
            var annotator1 = new Annotator { Name = "atr", Stat = Stat.Read };

            // Opening another annotator without closing the old annotator
            annotator1.Open("data/100s");
            Assert.IsTrue(annotator1.IsOpen);
            var expectedAnnotations1 = annotator1.ReadAll().ToList();

            var annotator2 = new Annotator { Name = "hrv", Stat = Stat.Read };
            annotator2.Open("data/100s");
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);
            var expectedAnnotations2 = annotator2.ReadAll().ToList();

            // Closing the first annotator and keeping the second one
            annotator1.Close();
            Assert.IsFalse(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            var annotations2 = annotator2.ReadAll();
            Assert.AreEqual(expectedAnnotations2, annotations2);

            // Reopening the first annotator, this time it should have the 1 number
            annotator1.Open("data/100s");
            var annotations1 = annotator1.ReadAll();
            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotator1.Close();
            annotator2.Close();
            Assert.IsFalse(annotator1.IsOpen);
            Assert.IsFalse(annotator2.IsOpen);

            // Reopening in the same order
            annotator1.Open("data/100s"); //0
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsFalse(annotator2.IsOpen);

            annotator2.Open("data/100s"); //1
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            // Reading Some data
            annotations1 = annotator1.ReadAll();  // 0
            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotations2 = annotator2.ReadAll(); // 1
            Assert.AreEqual(expectedAnnotations2, annotations2);

            annotator1.Close();
            annotator2.Close();

            // reopening in an inversed order
            annotator2.Open("data/100s"); //0
            Assert.IsTrue(annotator2.IsOpen);
            Assert.IsFalse(annotator1.IsOpen);

            annotator1.Open("data/100s"); //1
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            // Reading Some data
            annotations1 = annotator1.ReadAll();  // 0
            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotations2 = annotator2.ReadAll(); // 1
            Assert.AreEqual(expectedAnnotations2, annotations2);

            annotator1.Close();
            annotator2.Close();
        }
 public void ReadAllClosedAnnotatorTest()
 {
     var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
     annotator.Open("data/100s");
     annotator.Close();
     annotator.ReadAll().ToList(); // force a loop
 }
        public void ReadAllOpenedAnnotatorTest()
        {
            var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
            annotator.Open("data/100s");
            var expectedAnnotations = new List<Annotation>();

            while (!annotator.IsEof)
            {
                expectedAnnotations.Add(annotator.ReadNext());
            }
            Assert.IsTrue(annotator.IsEof);
            annotator.Seek(Time.Zero);

            var annotations = annotator.ReadAll();
            Assert.AreEqual(expectedAnnotations, annotations);
            annotator.Close();

            // Reopening
            annotator.Open("data/100s");
            annotations = annotator.ReadAll();
            Assert.AreEqual(expectedAnnotations, annotations);
            annotator.Close();
        }
        public void ReadNextCountTest()
        {
            var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
            annotator.Open("data/100s");

            // Gets the total number of annotations available in the current annotator file.
            var availableAnnotationsCount = annotator.ReadAll().Count();
            // Reset the pointer to the first annotation.
            annotator.Seek(Time.Zero);

            // Read all using ReadNext(Count)
            var readCount = annotator.ReadNext(availableAnnotationsCount).Count();
            Assert.AreEqual(availableAnnotationsCount, readCount);
            Assert.IsTrue(annotator.IsEof);

            // Cant read when the
            readCount = annotator.ReadNext(1).Count();
            Assert.AreEqual(0, readCount);

            // Seeking to the middle of the file.
            var middle = availableAnnotationsCount / 2;
            annotator.Seek(Time.Zero);
            annotator.Seek(middle);

            readCount = annotator.ReadNext(availableAnnotationsCount).Count();
            Assert.AreEqual(availableAnnotationsCount - middle, readCount);

            Assert.IsTrue(annotator.IsEof);

            // Testing boundaries
            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(1).Count();
            Assert.AreEqual(1, readCount);

            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(availableAnnotationsCount + 1).Count();
            Assert.AreEqual(availableAnnotationsCount, readCount);

            annotator.Seek(Time.Zero);
            readCount = annotator.ReadNext(int.MaxValue).Count();
            Assert.AreEqual(availableAnnotationsCount, readCount);

            // Testing invalid values.
            try
            {
                annotator.ReadNext(-1).ToList(); // force loop
                Assert.Fail("ArgumentOutOfRangeException should have been thrown.");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            annotator.Close();
        }
Exemplo n.º 24
0
        public void OpenNAnnotatorValidRecord()
        {
            var annotator1 = new Annotator {
                Name = "atr", Stat = Stat.Read
            };

            // Opening another annotator without closing the old annotator
            annotator1.Open("data/100s");
            Assert.IsTrue(annotator1.IsOpen);
            var expectedAnnotations1 = annotator1.ReadAll();

            var annotator2 = new Annotator {
                Name = "hrv", Stat = Stat.Read
            };

            annotator2.Open("data/100s");
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);
            var expectedAnnotations2 = annotator2.ReadAll();

            // Closing the first annotator and keeping the second one
            annotator1.Close();
            Assert.IsFalse(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            var annotations2 = annotator2.ReadAll();

            Assert.AreEqual(expectedAnnotations2, annotations2);

            // Reopening the first annotator, this time it should have the 1 number
            annotator1.Open("data/100s");
            var annotations1 = annotator1.ReadAll();

            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotator1.Close();
            annotator2.Close();
            Assert.IsFalse(annotator1.IsOpen);
            Assert.IsFalse(annotator2.IsOpen);

            // Reopening in the same order
            annotator1.Open("data/100s"); //0
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsFalse(annotator2.IsOpen);

            annotator2.Open("data/100s"); //1
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            // Reading Some data
            annotations1 = annotator1.ReadAll();  // 0
            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotations2 = annotator2.ReadAll(); // 1
            Assert.AreEqual(expectedAnnotations2, annotations2);

            annotator1.Close();
            annotator2.Close();

            // reopening in an inversed order
            annotator2.Open("data/100s"); //0
            Assert.IsTrue(annotator2.IsOpen);
            Assert.IsFalse(annotator1.IsOpen);

            annotator1.Open("data/100s"); //1
            Assert.IsTrue(annotator1.IsOpen);
            Assert.IsTrue(annotator2.IsOpen);

            // Reading Some data
            annotations1 = annotator1.ReadAll();  // 0
            Assert.AreEqual(expectedAnnotations1, annotations1);

            annotations2 = annotator2.ReadAll(); // 1
            Assert.AreEqual(expectedAnnotations2, annotations2);

            annotator1.Close();
            annotator2.Close();
        }
        public void IsEofTest()
        {
            var annotator = new Annotator { Name = "atr", Stat = Stat.Read };

            annotator.Open("data/100s");

            Assert.IsFalse(annotator.IsEof);

            // Reading some data
            annotator.ReadNext();
            Assert.IsFalse(annotator.IsEof);

            // Reading all available annotations.
            annotator.ReadAll().ToList(); // force a loop over the enumerator.
            Assert.IsTrue(annotator.IsEof);

            // Seeking to the beginning.
            annotator.Seek(Time.Zero);
            Assert.IsFalse(annotator.IsEof);

            annotator.ReadAll();
            annotator.Close();
            Assert.IsFalse(annotator.IsOpen);
            // Reopening
            annotator.Open("data/100s");
            Assert.IsFalse(annotator.IsEof);
            annotator.Close();
        }
 public void CloseUnopenedAnnotatorTest()
 {
     var annotator = new Annotator { Name = "atr", Stat = Stat.Read };
     annotator.Close();
 }