Exemple #1
0
        public void Validate(Stream mp3Stream)
        {
            EventWeaver weaver = new EventWeaver();

            StreamProcessService streamService;
            ValidationFailureCollectorService validationService;

            streamService = new StreamProcessService(mp3Stream);
            validationService = new ValidationFailureCollectorService();
            validationService.OnValidationFailure += ValidationFailureEventHandler;

            weaver.Add(streamService);
            weaver.Add(new Mp3CrawlerService());
            weaver.Add(new LameHeaderService());

            weaver.Add(new BrokenFrameValidator());
            weaver.Add(new JunkDataValidator());
            weaver.Add(new LameHeaderPresentValidator());
            weaver.Add(new LameInfoCrcValidator());
            weaver.Add(new LameMusicCrcValidator());
            weaver.Add(new FrameCrcValidator());
            weaver.Add(new AverageBitrateValidator());

            weaver.Add(validationService);

            streamService.Begin();
        }
        public void Begin_NullEventsTest()
        {
            StreamProcessService p = new StreamProcessService(Stream.Null);

            // Don't throw
            p.Begin();
        }
        public void Begin_EndEventArgsTest()
        {
            Stream s = new MemoryStream();
            StreamProcessService p = new StreamProcessService(s);

            EndStreamProcessEventArgs args = null;

            p.OnEndStreamProcess +=
                delegate(EndStreamProcessEventArgs e)
                {
                    args = e;
                };

            p.Begin();
            Assert.IsNotNull(args);
        }
        public void Begin_BeginEventArgsTest()
        {
            Stream s = new MemoryStream();
            StreamProcessService p = new StreamProcessService(s);

            BeginStreamProcessEventArgs args = null;

            p.OnBeginStreamProcess +=
                delegate(BeginStreamProcessEventArgs e)
                {
                    args = e;
                };

            p.Begin();
            Assert.IsNotNull(args);
            Assert.AreEqual(s, args.Stream);
        }
        public void Begin_EventsTest()
        {
            StreamProcessService p = new StreamProcessService(Stream.Null);

            int count = 0;

            p.OnBeginStreamProcess +=
                delegate(BeginStreamProcessEventArgs e)
                {
                    count++;
                };

            p.OnEndStreamProcess +=
                delegate(EndStreamProcessEventArgs e)
                {
                    Assert.AreEqual(1, count++);
                };

            p.Begin();
            Assert.AreEqual(2, count);
        }
        public void Begin_ThrowBeginEventTest()
        {
            StreamProcessService p = new StreamProcessService(Stream.Null);

            bool calledEndEvent = false;
            p.OnBeginStreamProcess +=
                delegate(BeginStreamProcessEventArgs e)
                {
                    throw new Exception();
                };
            p.OnEndStreamProcess +=
                delegate(EndStreamProcessEventArgs e)
                {
                    calledEndEvent = true;
                };

            p.Begin();
            Assert.IsTrue(calledEndEvent);
        }
 public void Constructor_NullTest()
 {
     StreamProcessService p = new StreamProcessService(null);
 }
        public void Begin_ThrowEndEventTest()
        {
            StreamProcessService p = new StreamProcessService(Stream.Null);

            p.OnEndStreamProcess +=
                delegate(EndStreamProcessEventArgs e)
                {
                    throw new Exception();
                };

            // Don't throw
            p.Begin();
        }