public void NotAllowLogForWarningConsole() { string sMessage = "Test Warning not allowed console"; myMessageType = JobLogger.MessageType.Warning; //sends a type warning JobLogger.ConfigJobLogger(false, true, false, false, false, true); string sExpectedMessage = ""; Console.SetOut(stringWriter); JobLogger.LogMessage(sMessage, myMessageType); Assert.AreEqual(sExpectedMessage, stringWriter.ToString()); }
public void NotAllowLogForDataBaseAnyType() { string sMessage = "My test log not allowed in database"; myMessageType = JobLogger.MessageType.Error; JobLogger.ConfigJobLogger(false, false, false, true, true, true); string sQuery = dbHelper.GetSelectQuery(sMessage, myMessageType); JobLogger.LogMessage(sMessage, myMessageType); string sSavedMessage = dbHelper.GetMessageFromRegister(sQuery); Assert.AreEqual(sExpectedMessage, sSavedMessage); }
public void RegisterOnlyMessagesDataBase() { string sMessage = "My test message in data base"; myMessageType = JobLogger.MessageType.Message; JobLogger.ConfigJobLogger(false, false, true, true, false, false); string sQuery = dbHelper.GetSelectQuery(sMessage, myMessageType); JobLogger.LogMessage(sMessage, myMessageType); sExpectedMessage = dbHelper.GetMessageFromRegister(sQuery); Assert.AreEqual(sMessage, sExpectedMessage); }
public void RegisterOnlyMessagesTextFile() { string sMessage = "My test type Message in text file"; myMessageType = JobLogger.MessageType.Message; JobLogger.ConfigJobLogger(true, false, false, true, false, false); string sExpectedMessage = string.Format("{0} - {1} : {2}", myMessageType.ToString(), DateTime.Now, sMessage); JobLogger.LogMessage(sMessage, myMessageType); string sMessageRegistered = System.IO.File.ReadLines(sFileName).Last(); Assert.AreEqual(sExpectedMessage, sMessageRegistered); }
public void RegisterOnlyErrorsTextFile() { //Arrange string sMessage = "Test type Error in text file"; myMessageType = JobLogger.MessageType.Error; JobLogger.ConfigJobLogger(true, false, false, false, false, true);//Config to register log of only errors in a text file string sExpectedMessage = string.Format("{0} - {1} : {2}", myMessageType.ToString(), DateTime.Now, sMessage); //Act JobLogger.LogMessage(sMessage, myMessageType); //Assert string sMessageRegistered = System.IO.File.ReadLines(sFileName).Last(); Assert.AreEqual(sExpectedMessage, sMessageRegistered); }