Example #1
0
        /// <summary>
        /// Function that returns the average session duration for a month
        /// </summary>
        /// <param name="month">referenced month</param>
        /// <param name="year">referenced year</param>
        /// <returns>An object that holds the number the average session duration for a month</returns>
        public List <UADObject> GetAverageSessionDuration(string month, int year)
        {
            string[] logID           = { "EntryToWebsite", "ExitFromWebsite" };
            string[] informationList = { "Average Session Duration", "Minimum Session Duration", "Maximum Session Duration" };
            var      sessions        = new List <GNGLog>();
            var      sessionInfo     = new List <string> {
                "0", "0", "0"
            };

            loglist = _gngLoggerService.ReadLogsGivenMonthYear(month, year);
            // Get two seperate logs
            var entryToWebsite = _uadService.GetLogswithID(loglist, logID[0]);
            // Get exit from website logs
            var exitFromWebsite = _uadService.GetLogswithID(loglist, logID[1]);

            // Pair sessions beginning and ending logs
            sessions = _uadService.PairStartAndEndLogs(entryToWebsite, exitFromWebsite);
            if (sessions.Count > 0)
            {
                sessionInfo = _uadService.CalculateSessionInformation(sessions);
            }
            var date = month + " " + year;

            monthsUsed.Add(date);
            uadObjects.AddRange(_uadService.ConvertListToUADObjects(monthsUsed, informationList, sessionInfo));
            monthsUsed.Clear();

            return(uadObjects);
        }
Example #2
0
        public void CalculateAverageSessionTime_Pass()
        {
            // Arrange
            LoggerService _loggerService = new LoggerService();
            bool          expected       = true;
            bool          actual         = false;

            // Read logs from this path
            string        path    = "C:\\Users\\Midnightdrop\\Documents\\GitHub\\GreetNGroup\\Backend\\UnitTest\\UADTest\\TestLogs\\ServiceLogs\\PassLogs_SessionTimes";
            List <GNGLog> logList = new List <GNGLog>();

            // Act
            logList = _loggerService.ReadLogsPath(path);
            var averageTime = _uadService.CalculateSessionInformation(logList);

            if (averageTime[0].CompareTo("60") == 0)
            {
                actual = true;
            }
            Assert.AreEqual(actual, expected);
        }