Exemple #1
0
        public void GetAllLogs()
        {
            IMsSqlLogService repository = new MsSqlLogService();
            LogController controller = new LogController(repository);

            // get list of Logs
            int initialCount = 0; // controller.GetAllLogs().Count();

            // lets create 5 entries
            LogTO log1 = InsertLog("First Message", "Source 1", LogTO.LogType.Error);
            LogTO log2 = InsertLog("Second Message", "Source 2", LogTO.LogType.Info);
            LogTO log3 = InsertLog("Third Message", "Source 3", LogTO.LogType.Trace);
            LogTO log4 = InsertLog("Fourth Message", "Source 4", LogTO.LogType.Trace);
            LogTO log5 = InsertLog("Fifth Message", "Source 5", LogTO.LogType.Error);

            // get list of Logs
            int FinalCount = 0; // controller.GetAllLogs().Count();

            // check if 5 records are created and found by function
            Assert.AreEqual(initialCount + 5 , FinalCount);

            // delete 5 created logs
            repository.Delete(log1.LogId);
            repository.Delete(log2.LogId);
            repository.Delete(log3.LogId);
            repository.Delete(log4.LogId);
            repository.Delete(log5.LogId);
        }
Exemple #2
0
        public void FindLog()
        {
            IMsSqlLogService repository = new MsSqlLogService();
            LogController controller = new LogController(repository);

            // lets create 1 log
            LogTO log = InsertLog("First Message", "Source 1", LogTO.LogType.Error);

            // find the log and compare
            LogTO logFound = controller.FindLog(log.LogId);

            // if null the issue
            Assert.IsNotNull(logFound);

            Assert.AreEqual(log.LogId, logFound.LogId, "LogId found is different");
            Assert.AreEqual(log.Message, logFound.Message, "Message inserted is not same");
            Assert.AreEqual(log.Source, logFound.Source, "Source is different");
            Assert.AreEqual(log.Type, logFound.Type,"Type is not same");

            repository.Delete(log.LogId);
        }
Exemple #3
0
        public void DeleteLog()
        {
            IMsSqlLogService repository = new MsSqlLogService();
                LogController controller = new LogController(repository);
                // lets create 1 log
                LogTO log = InsertLog("First Message", "Source 1", LogTO.LogType.Error);

                // Now lets delete the log
                repository.Delete(log.LogId);

            try
            {
                // this must raise exception
                LogTO logFound = controller.FindLog(log.LogId);

                // above line must throw not found exception, if we are here then
                // we found the record which is wrong
                Assert.Fail();
            }
            catch (Exception ex)
            {

            }
        }
Exemple #4
0
        private LogTO InsertLog(string message, string source, LogTO.LogType type)
        {
            IMsSqlLogService repository = new MsSqlLogService();
            LogController controller = new LogController(repository);
            LogTO log = new LogTO();
            log.Message = message;
            log.Source = source;
            log.Type = type.ToString();
            LogTO insertedLog =  repository.Insert(log);

            Assert.AreNotEqual(0, insertedLog.LogId, "Failed to insert");

            Assert.AreEqual(message, insertedLog.Message,"Message are not equal");
            Assert.AreEqual(source, insertedLog.Source,"Source is not equal");
            Assert.AreEqual(type.ToString(), insertedLog.Type,"type is not same");

            return insertedLog;
        }
Exemple #5
0
        public void InsertLog()
        {
            IMsSqlLogService repository = new MsSqlLogService();
            LogController controller = new LogController(repository);

            LogTO insertedLog = InsertLog("Test Message", "Test application", LogTO.LogType.Info);

            // function has already verified  so just remove for successfull completion
            // Remove it after completion
            repository.Delete(insertedLog.LogId);
        }