Example #1
0
 private static MainLog GetMainLog()
 {
     DateTime time = new DateTime(2014, 12, 31);
     MainLog log = new MainLog()
     {
         Message = "test",
         Scenario = 12,
         JobStartTime = time,
         JobEndTime = time,
         Error = new ErrorLog()
         {
             Message = "test",
             Time = time,
             StackTrace = "stack"
         }
     };
     return log;
 }
Example #2
0
        public void UpdateMainLog()
        {
            DateTime time = new DateTime(2014, 12, 31);
            MainLog log = new MainLog()
            {
                Message = "test",
                Scenario = 12,
                JobStartTime = time,
                JobEndTime = time
            };

            _repository.Add(log);

            log.Details = new List<DetailLog>();
            log.Details.Add(new DetailLog()
            {
                Message = "test",
                Time = time,
                Scenario = 12,
            });

            _repository.Add(log);

            Assert.AreEqual("test", log.Message);

            log.Message = "t";
            log = _repository.Update(log);

            Assert.AreEqual("t", log.Message);
            MainLog load = _repository.GetMain(log.Id);
            Assert.AreEqual("t", load.Message);
        }
Example #3
0
        public void SessionSaveLogDetailsInMainLog()
        {
            using (ISession session = NHibernateHelper.OpenSession())
            using (ITransaction transaction = session.BeginTransaction())
            {
                DateTime time = new DateTime(2014, 12, 31);
                MainLog log = new MainLog()
                {
                    Message = "test",
                    Scenario = 12,
                    JobStartTime = time,
                    JobEndTime = time
                };

                DetailLog dlog = new DetailLog()
                {
                    Message = "test",
                    Time = time,
                    Scenario = 12,
                };

                log.AddDetail(dlog);
                session.Save(log);

                Assert.AreNotEqual(0, dlog.Main.Id);

                transaction.Commit();

                MainLog loaded = _repository.GetMain(log.Id);
                Assert.AreEqual(log.Id, loaded.Id);
                Assert.AreEqual(log.Id, loaded.Details.First().Main.Id);
            }
        }
Example #4
0
        public void OrderedDetailsInMainLog()
        {
            DateTime time = new DateTime(2014, 12, 31);
            MainLog log = new MainLog()
            {
                Message = "test",
                Scenario = 12,
                JobStartTime = time,
                JobEndTime = time
            };

            _repository.Add(log);

            log.Details = new List<DetailLog>();
            log.Details.Add(new DetailLog()
            {
                Message = "test later later",
                Time = time.AddDays(2),
                Scenario = 12,
            });
            log.Details.Add(new DetailLog()
            {
                Message = "test later",
                Time = time.AddDays(1),
                Scenario = 12,
            });
            log.Details.Add(new DetailLog()
            {
                Message = "test sooner",
                Time = time,
                Scenario = 12,
            });

            _repository.Add(log);

            MainLog load = _repository.GetMain(log.Id);
            Assert.AreEqual("test sooner", load.Details[0].Message);
            Assert.AreEqual("test later", load.Details[1].Message);
        }
Example #5
0
        public void GetLasMainLog()
        {
            DateTime time = new DateTime(2014, 12, 31);
            DateTime time1 = new DateTime(2012, 12, 31);
            MainLog log = new MainLog()
            {
                Message = "test",
                Scenario = 1234,
                JobStartTime = time,
                JobEndTime = time
            };

            MainLog log1 = new MainLog()
            {
                Message = "test",
                Scenario = 1234,
                JobStartTime = time1,
                JobEndTime = time1
            };

            _repository.Add(log);
            _repository.Add(log1);

            MainLog loaded = _repository.GetLastMain(1234);
            Assert.AreEqual(log.Id, loaded.Id);
        }
Example #6
0
        public void AddNewMainLoglWithDetails()
        {
            DateTime time = new DateTime(2014, 12, 31);
            MainLog log = new MainLog()
            {
                Message = "test",
                Scenario = 12,
                JobStartTime = time,
                JobEndTime = time
            };

            DetailLog dlog = new DetailLog()
            {
                Message = "test",
                Time = time,
                Scenario = 12
            };

            log.AddDetail(dlog);
            _repository.Add(log);

            Assert.AreNotEqual(0, dlog.Main.Id);

            MainLog loaded = _repository.GetMain(log.Id);
            Assert.AreEqual(log.Id, loaded.Id);
            Assert.AreEqual(log.Id, loaded.Details.First().Main.Id);
        }