Esempio n. 1
0
        public void QuickSortInteger_Pass()
        {
            //Arrange
            var        _uadService = new UADService();
            bool       expected    = true;
            bool       actual      = false;
            List <int> numList     = new List <int> {
                5, 4, 3, 2, 1
            };
            List <string> wordList = new List <string> {
                "E", "D", "C", "B", "A"
            };

            //Act
            sortServicer.QuickSortInteger(numList, wordList, 0, wordList.Count - 1);
            if ((numList[0] == 1 && wordList[0].Equals("A")) && (numList[1] == 2 && wordList[1].Equals("B")) && (numList[2] == 3 && wordList[2].Equals("C")) && (numList[3] == 4 && wordList[3].Equals("D")) && (numList[4] == 5 && wordList[4].Equals("E")))
            {
                actual = true;
            }
            Assert.AreEqual(actual, expected);
        }
Esempio n. 2
0
        /// <summary>
        /// Function that returns the top 5 most used features of the website
        /// </summary>
        /// <param name="month">referenced month</param>
        /// <param name="year">referenced year</param>
        /// <returns>A list of objects that holds the top 5 most used features</returns>
        public List <UADObject> GetTop5MostUsedFeature(string month, int year)
        {
            var features = new List <String>()
            {
                "EventCreated", "EventJoined", "SearchAction", "FindEventForMe", "UserRatings"
            };
            var timesFeaturedUsed = new List <int>()
            {
            };

            loglist = _gngLoggerService.ReadLogsGivenMonthYear(month, year);
            // List of features wanting to be analyzed

            // For each feature get the amount of times they were used
            for (int j = 0; j < features.Count; j++)
            {
                // Get the log id for the feature
                var timesUsed = _uadService.GetNumberofLogsID(loglist, features[j]);
                timesFeaturedUsed.Add(timesUsed);
            }
            // Sort Features from
            _sortService.QuickSortInteger(timesFeaturedUsed, features, 0, features.Count - 1);
            if (features.Count >= 5)
            {
                for (int k = features.Count - 1; k >= features.Count - 5; k--)
                {
                    var sessionUADObject = new UADObject
                    {
                        Date     = month + ' ' + year,
                        InfoType = features[k],
                        Value    = timesFeaturedUsed[k].ToString()
                    };
                    uadObjects.Add(sessionUADObject);
                }
            }
            else
            {
                for (int k = features.Count - 1; k >= 0; k--)
                {
                    var sessionUADObject = new UADObject
                    {
                        Date     = month + ' ' + year,
                        InfoType = features[k],
                        Value    = timesFeaturedUsed[k].ToString()
                    };
                    uadObjects.Add(sessionUADObject);
                }
            }

            return(uadObjects);
        }