public async Task <string> Handle(SortingNumbersCommand request, CancellationToken cancellationToken) { try { int[] numbersArray = NumbersDataConverter.Convert(request.Numbers); _sortingService.Sort(numbersArray); //await if accepted and async req reply pattern return(await _fileManager.WriteToFile(numbersArray)); } catch (Exception ex) { _logger.LogError("An unhandled error occurred.", ex); throw new SSException("Sorry, something goes wrong on our server. Please, write to our support: [email protected]"); } }
public void WrongDataToArrayTest(string source) { Assert.Throws <SSException>(() => NumbersDataConverter.Convert(source)); }
public void ConvertResultArrayToString() { string res = NumbersDataConverter.Convert(new int[] { 1, 2, 3, 5, 7, 110 }); Assert.Equal("1 2 3 5 7 110", res); }
public void ConvertStringToArrayTest(string source, int[] expectedResult) { int[] result = NumbersDataConverter.Convert(source); Assert.Equal(result, expectedResult); }