Ejemplo n.º 1
0
        public void DbMakeChangesTest()
        {
            var context = new D2SLogContext(DeployDatabaseIfNotExist: true);
            var a       = context.RunLogEntries;
            var b       = context.taskLogEntries;

            RunLogEntry entry = new RunLogEntry()
            {
                Source      = "Test",
                Target      = "Test",
                UserName    = "******",
                Status      = "Running",
                StartTime   = DateTime.Now,
                MachineName = "Test",
                Tasks       = new List <TaskLogEntry>()
                {
                    new TaskLogEntry()
                    {
                        TaskName  = "Test",
                        Target    = "Test",
                        Status    = "Running",
                        StartTime = DateTime.Now,
                    }
                }
            };

            a.Add(entry);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void D2SLogContextDbSetTest()
        {
            var context = new D2SLogContext();
            var a       = context.RunLogEntries;
            var b       = context.taskLogEntries;

            Assert.IsNotNull(a);
            Assert.IsNotNull(b);
        }
Ejemplo n.º 3
0
        public void UndesiredDatabaseMigrationPreventionTest()
        {
            //drop the DB first, or at least make sure its gone
            var c = new D2SLogContext(true);

            c.Database.Delete();
            c.SaveChanges();
            c.Dispose();

            var context = new D2SLogContext(false);

            Assert.ThrowsException <EntityException>(() => addTask(context));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Closes the previously opened logentry with either a success or failure code.
        /// </summary>
        /// <remarks>
        /// If this method  is not called, any log entries written will be lost.
        /// </remarks>
        /// <param name="processWasSuccessfull">A bool indicating if the process has completed successfully</param>
        public void CloseLogEntry(bool processWasSuccessfull)
        {
            if (!SqlLogEnabled)
            {
                return;
            }
            if (!_hasOpenLogEntry)
            {
                var outputMessage = "Attempted to close a log entry when no log entry was open";
                LogService.Instance.Error(outputMessage);
                throw new InvalidOperationException(outputMessage);
            }
            else
            {
                DateTime endTime = DateTime.Now;
                string   status  = processWasSuccessfull ? "SUCCESS" : "FAILED";

                try
                {
                    _runLogEntry.Status  = status;
                    _runLogEntry.EndTime = endTime;
                    D2SLogContext context = new D2SLogContext(false);
                    context.RunLogEntries.Add(_runLogEntry);
                    context.SaveChanges();
                }
                catch (SqlException sqlEx)
                {
                    LogService.Instance.Error(sqlEx);
                    throw;
                }
                catch (Exception ex)
                {
                    LogService.Instance.Error(ex);
                    throw;
                }

                _hasOpenLogEntry = false;
            }
        }
Ejemplo n.º 5
0
        public static void ClassInit(TestContext testContext)
        {
            D2SLogContext context = new D2SLogContext(true);

            context.Database.CreateIfNotExists();
        }
Ejemplo n.º 6
0
 private void addTask(D2SLogContext c)
 {
     c.RunLogEntries.Add(new RunLogEntry());
     c.SaveChanges();
 }
Ejemplo n.º 7
0
        public void D2SLogContextTest()
        {
            var context = new D2SLogContext();

            Assert.IsNotNull(context);
        }