コード例 #1
0
        public void ConvertToListOfNumbers_NullStringOfNumbers_ShouldThrowException()
        {
            string stringOfNumbers = null;
            char   delimiter       = ' ';

            Assert.Throws <NullReferenceException>(() => _conversionLogic.ConvertToListOfNumbers(stringOfNumbers, delimiter));
        }
コード例 #2
0
        public SortResponseDTO Sort(string stringOfNumbers)
        {
            try
            {
                var numberList = _conversionLogic.ConvertToListOfNumbers(stringOfNumbers, ' ');

                var firstCopyOfNumberList  = new List <long>(numberList);
                var secondCopyOfNumberList = new List <long>(numberList);
                var thirdCopyOfNumberList  = new List <long>(numberList);

                var firstResult  = SortUsingAlgorithm(ESortingAlgorithms.BubbleSort, firstCopyOfNumberList);
                var secondResult = SortUsingAlgorithm(ESortingAlgorithms.InsertionSort, secondCopyOfNumberList);
                var thirdResult  = SortUsingAlgorithm(ESortingAlgorithms.QuickSort, thirdCopyOfNumberList);

                var stringOfOrderedNumbers = _conversionLogic.ConvertToStringOfNumbers(firstCopyOfNumberList, ' ');
                _sortingRepository.SaveSortedNumbers(stringOfOrderedNumbers);

                return(new SortResponseDTO()
                {
                    SortedNumbers = stringOfOrderedNumbers,
                    AlgortihmPerformance = new List <SortAlgorithmResponseDTO>()
                    {
                        firstResult, secondResult, thirdResult
                    }
                });
            }
            catch
            {
                return(null);
            }
        }