예제 #1
0
        public void Add2NewLogDetail()
        {
            MainLog load = _repository.GetMain(mainGuid);
            int count = load.Details.Count;

            DetailLog log = new DetailLog()
            {
                Message = "test",
                Scenario = 12,
                Time = new DateTime(2014, 12, 31),
            };

            load.AddDetail(log);

            DetailLog log1 = new DetailLog()
            {
                Message = "test1",
                Scenario = 12,
                Time = new DateTime(2014, 12, 31),
            };

            load.AddDetail(log1);
            _repository.Update(load);

            load = _repository.GetMain(mainGuid);
            Assert.AreEqual(mainGuid, load.Id);

            Assert.AreEqual(count + 2, load.Details.Count);
        }
예제 #2
0
 public virtual void AddDetail(DetailLog Detail)
 {
     Detail.Main = this;
     Details.Add(Detail);
 }
예제 #3
0
 public void TwoRepMainDetailLoad()
 {
     DateTime time = new DateTime(2014, 12, 31);
     MainLog log = _repository.GetMain(mainGuid);
     int count = log.Details.Count;
     DetailLog det = new DetailLog()
     {
         Time = time,
         Message = "eee"
     };
     log.AddDetail(det);
     _repository.Update(log);
     MainLog loaded = new Repository().GetMain(log.Id);
     Assert.AreEqual(count + 1, loaded.Details.Count);
 }
예제 #4
0
        public void DetailLogErrorLoad()
        {
            DateTime time = new DateTime(2014, 12, 31);
            DetailLog log = new DetailLog()
            {
                Message = "xxx",
                Time = time
            };
            log.Error = new ErrorLog()
            {
                Message = "error",
                Time = time
            };
            _repository.Add(log);
            Assert.AreNotEqual(0, log.Error.Id);
            Assert.AreNotEqual("", log.Id.ToString());

            DetailLog loaded = _repository.GetDetail(log.Id);
            Assert.AreEqual(loaded.Error.Message, log.Error.Message);
        }
예제 #5
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);
            }
        }
예제 #6
0
        public void AddNewMainLoglWithDetailsAlreadyLoaded()
        {
            DateTime time = new DateTime(2014, 12, 31);
            MainLog log = _repository.GetMain(mainGuid);
            int count = log.Details.Count;
            DetailLog dlog = new DetailLog()
            {
                Message = "test",
                Time = time,
                Scenario = 12
            };

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

            MainLog loaded = _repository.GetMain(log.Id);
            Assert.AreEqual(count + 1, loaded.Details.Count);

            DetailLog dlog1 = new DetailLog()
            {
                Message = "test1",
                Time = time,
                Scenario = 12
            };

            loaded.AddDetail(dlog1);
            _repository.Update(loaded);

            loaded = _repository.GetMain(log.Id);
            Assert.AreEqual(count + 2, loaded.Details.Count);
        }
예제 #7
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);
        }
예제 #8
0
        public void AddNewLogDetailWithErrorAndGetError()
        {
            DateTime time = new DateTime(2014, 12, 31);
            DetailLog log = new DetailLog()
            {
                Message = "test",
                Scenario = 12,
                Time = time,
                Error = new ErrorLog()
                {
                    Message = "test",
                    Time = time,
                    StackTrace = "stack"
                }
            };

            _repository.Add(log);
            Assert.AreNotEqual(0, log.Error.Id);
            Assert.AreNotEqual("", log.Id.ToString());

            DetailLog loaded = _repository.GetDetail(log.Id);
            Assert.IsNotNull(loaded.Error);
        }
예제 #9
0
        public void AddNewLogDetailAndGetDetail()
        {
            DateTime time = new DateTime(2014, 12, 31);
            DetailLog log = new DetailLog()
            {
                Message = "test",
                Scenario = 12,
                Time = time,
            };

            _repository.Add(log);
            Assert.AreNotEqual("", log.Id.ToString());

            DetailLog loaded = _repository.GetDetail(log.Id);
            Assert.AreEqual("test", loaded.Message);
        }
예제 #10
0
        public void AddIndependentNewLogDetail()
        {
            MainLog mainLog = _repository.GetMain(mainGuid);
            int count = mainLog.Details.Count;
            DetailLog logDetail = new DetailLog()
            {
                Message = "test",
                Scenario = 12,
                Time = DateTime.Now,
                Main = new MainLog() { Id = mainGuid }
            };

            _repository.Add(logDetail);
            MainLog load = _repository.GetMain(mainGuid);
            Assert.AreEqual(mainGuid, load.Id);
            Assert.AreEqual(count + 1, load.Details.Count);
        }