Пример #1
0
        public void Contructor_bTest()
        {
            IViewer      viewer       = new MockViewer();
            ListenerBase listenerBase = new MockListener();
            var          s            = new Session(listenerBase, viewer);

            Assert.AreEqual("", s.Title);
            Assert.AreSame(viewer, s.Viewer);
        }
Пример #2
0
        public void ViewerTest()
        {
            IViewer viewer = new MockViewer();
            var     s      = new Session();

            s.Viewer = viewer;

            Assert.AreSame(viewer, s.Viewer);
        }
Пример #3
0
        public void Contructor_bTest()
        {
            Viewers.IViewer     viewer   = new MockViewer();
            Listeners.IListener listener = new MockListener();
            Session             s        = new Session(listener, viewer);

            Assert.AreEqual("", s.Title);
            Assert.AreSame(viewer, s.Viewer);
        }
        public void NonExistingFile()
        {
            var v = new MockViewer();
            var f = new FileListener(@"c:\finns_inte.foo", 10, "foo", true);
            var s = new Session(f, v);

            s.Start();
            Thread.Sleep(500);
            s.Stop();
        }
Пример #5
0
 public void InitializeTest()
 {
     _session   = new Session();
     _listenerA = new MockListener();
     _listenerB = new MockListener();
     _session.AddListener(_listenerA);
     _session.AddListener(_listenerB);
     _viewer         = new MockViewer();
     _session.Viewer = _viewer;
 }
Пример #6
0
        public void LogFileNotCreated()
        {
            Listeners.IListener listener = new MockListener();
            Viewers.IViewer     viewer   = new MockViewer();

            SessionMonitor s = new SessionMonitor(listener, viewer);

            s.Start();
            s.AddEvent(listener, "Some text");
            s.Stop();

            Assert.IsNull(s.logFileName);
        }
Пример #7
0
        public void Initialize()
        {
            int interval = 300;

            if (!EventLog.Exists(_logName, "."))
            {
                EventLog.CreateEventSource(new EventSourceCreationData(_source, _logName));
            }
            _eventLog = new EventLog(_logName, ".");
            _eventLog.Clear();
            _viewer   = new MockViewer();
            _listener = new EventLogListenerMonitor(".", _logName, interval, true);
            _session  = new Session(_listener, _viewer);
        }
Пример #8
0
        public void LogFileCreated()
        {
            Viewers.IViewer     viewer   = new MockViewer();
            Listeners.IListener listener = new MockListener();
            SessionMonitor      s        = new SessionMonitor(listener, viewer, "foo_log.txt");

            s.Start();
            s.AddEvent(listener, "Some text");
            s.Stop();

            Assert.IsTrue(System.IO.File.Exists(s.logFileName));

            System.IO.File.Delete(s.logFileName);
        }
        public void ShowExistingFileData()
        {
            var v = new MockViewer();
            var f = createFile();

            File.WriteAllText(f, "some random text");
            var fl = new FileListener(f, 3, "foo", false);
            var s  = new Session(fl, v);

            s.Start();
            Application.DoEvents();
            Thread.Sleep(200);
            Application.DoEvents();
            Assert.IsTrue(v.ReceivedData.Count > 0);

            s.Stop();
        }
Пример #10
0
        public void DontShowExistingFileData()
        {
            MockViewer v = new MockViewer();
            string     f = createFile();

            File.WriteAllText(f, "some random text");
            FileListener fl = new FileListener(f, 3, "foo", true);
            Session      s  = new Session(fl, v);

            s.Start();
            System.Windows.Forms.Application.DoEvents();
            Thread.Sleep(200);
            System.Windows.Forms.Application.DoEvents();

            Assert.AreEqual(0, v.ReceivedData.Count);

            s.Stop();
        }
        public void ShowOnlyNewFileData()
        {
            var v = new MockViewer();
            var f = createFile();

            File.WriteAllText(f, "some random text");
            var fl = new FileListener(f, 3, "foo", true);
            var s  = new Session(fl, v);

            s.Start();
            Thread.Sleep(200);
            Application.DoEvents();

            File.AppendAllText(f, "some more random text");
            Thread.Sleep(200);

            Application.DoEvents();

            Assert.AreEqual(1, v.ReceivedData.Count);

            s.Stop();
        }
        public void ShowNewAndOldFileData()
        {
            var v = new MockViewer();
            var f = createFile();

            File.WriteAllText(f, "some random text");
            var fl = new FileListener(f, 3, "foo", false);
            var s  = new Session(fl, v);

            s.Start();

            Application.DoEvents();
            Thread.Sleep(200); //If this is to short the test will fail.
            Application.DoEvents();

            File.AppendAllText(f, "some more random text");
            Thread.Sleep(200); //If this is to short the test will fail.
            Application.DoEvents();

            Assert.AreEqual(2, v.ReceivedData.Count);

            s.Stop();
        }
Пример #13
0
 public void InitializeTest()
 {
     _viewer   = new MockViewer();
     _listener = new UdpListener(_testEndpoint, _testPort, "");
     _session  = new Session(_listener, _viewer);
 }