public void Log(string message) { using (DatabaseContextLog context = new DatabaseContextLog()) { context.Logs.Add(new LogDTO() { Message = message, Time = DateTime.Now, }); context.SaveChanges(); } }
public void Logger_IsExistARow() { DBLogger logger = new DBLogger(); DatabaseContextLog DBL = new DatabaseContextLog(); int temp = DBL.Logs.Count(); string testString = "Test"; logger.Log(testString); Assert.AreEqual(temp + 1, DBL.Logs.Count()); Assert.AreEqual(DBL.Logs.OrderByDescending(p => p.Time).FirstOrDefault().Message, testString); }