예제 #1
0
        public void _0001_ListingLogDirectory_Async()
        {
            var loadingCompleteEvent = new AutoResetEvent(false);

            ILogFileCollection logfiles = new LogFileCollection();

            Action asyncMethod = () =>
            {
                logfiles.Load(LogLocation, ProjectName);
            };

            AsyncCallback callback = (iftAr) =>
            {
                loadingCompleteEvent.Set();
            };

            logfiles.ProgressChanged += (o, e) => { Console.WriteLine("Percent:" + e.ProgressPercentage + "%" + " Message:" + e.UserState); };

            asyncMethod.BeginInvoke(callback, null);

            loadingCompleteEvent.WaitOne();
            foreach (ILogFileItem item in logfiles)
            {
                Console.WriteLine(item.Name);
            }


            Assert.IsTrue(logfiles.Count != 0, "Nincs log fál a kövekező utvonalon:" + LogLocation);
        }
예제 #2
0
        public void _0010_NewLogFile_Add_LogFileCollection()
        {
            var logFileName = "_0007_NewLogFile_Add_LogFileCollection" + Guid.NewGuid().ToString();
            var newLog      = new LogFileItem(LogLocation, ProjectName, logFileName);

            Assert.IsTrue(System.IO.File.Exists(newLog.Path), "Nem hozta létre a log fájlt.");
            newLog.Messages.AddToStorageBegin();
            for (int i = 0; i < 100; i++)
            {
                newLog.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Received, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
            }
            newLog.Messages.AddToStorageEnd();

            var logFiles = new LogFileCollection();

            logFiles.Load(LogLocation, ProjectName);
            AutoResetEvent completeEvent = new AutoResetEvent(false);

            logFiles.ListChanged += (o, e) =>
            {
                if (e.ListChangedType == ListChangedType.ItemAdded)
                {
                    completeEvent.Set();
                }
            };
            logFiles.Add(newLog);
            Assert.True(completeEvent.WaitOne(1000), "Nem j0tt meg az esény az új logfile beszurásáról.");
        }
예제 #3
0
        public void _0002_ListingLogDirectory_Sync()
        {
            ILogFileCollection logfiles = new LogFileCollection();

            logfiles.ProgressChanged += (o, e) => { Console.WriteLine("Percent:" + e.ProgressPercentage + "%" + " Message:" + e.UserState); };
            logfiles.Load(LogLocation, ProjectName);
            foreach (ILogFileItem item in logfiles)
            {
                Console.WriteLine(item.Name);
            }
            Assert.IsTrue(logfiles.Count != 0, "Nincs log fál a kövekező utvonalon:" + LogLocation);
        }
예제 #4
0
        public void _0009_PropretyTest()
        {
            ILogFileCollection logfiles = new LogFileCollection();

            logfiles.ProgressChanged += (o, e) => { Console.WriteLine("Percent:" + e.ProgressPercentage + "%" + " Message:" + e.UserState); };
            logfiles.Load(LogLocation, ProjectName);

            var logFileName = DateTime.Now.ToString("yyMMdd HHmmss") + "_0006_PropretyTest_" + Guid.NewGuid().ToString();

            ILogFileItem log = null;

            if (!System.IO.File.Exists(LogLocation + logFileName + ".s3db"))
            {
                log = new LogFileItem(LogLocation, ProjectName, logFileName);
                Assert.IsTrue(System.IO.File.Exists(log.Path), "Nem hozta létre a log fájlt.");
                log.Messages.AddToStorageBegin();
                for (int i = 0; i < 2; i++)
                {
                    log.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Transmitted, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
                    log.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Received, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
                }
                log.Messages.AddToStorageEnd();
            }



            AutoResetEvent completeEvetn = new AutoResetEvent(false);

            log.Statistics.PropertyChanged += (o, e) =>
            {
                Assert.True(e.PropertyName == "ReceivedMessageCount" || e.PropertyName == "TransmittedMessageCount");
                completeEvetn.Set();
            };

            var logFile = (logfiles as LogFileCollection).FirstOrDefault(n => n.Name == logFileName);

            log.Load();

            Assert.False(completeEvetn.WaitOne(1000) == false, "Nem jött esemény.");

            Assert.AreEqual(2, log.Statistics.ReceivedMessageCount);
            Assert.AreEqual(2, log.Statistics.TransmittedMessageCount);

            foreach (var item in log.Messages)
            {
                Console.WriteLine(item.ToString());
            }
        }