public void Run() { try { if (!_checker.IsNumber()) { _consoleViewer.ShowMessage(DefaultSettings.NO_NUMBER); return; } if (!_checker.IsAboveThanZero()) { _consoleViewer.ShowMessage(DefaultSettings.LESS_THAN_ZERO); return; } long lastNumber = long.Parse(_finishRange); NumericalSequence naturalNumbers = new NumericalSequence(lastNumber); IEnumerable <long> sequence = naturalNumbers.GetNumbers(); _consoleViewer.ShowSequence(sequence); } catch (OverflowException ex) { _consoleViewer.ShowMessage(string.Format("{0}\n{1}", ex.Message, _instruction)); } }
public void NumericalSequence_WithMaxSquare_ShouldReturnSequence(int maxSquare, params int[] expected) { NumericalSequence sequence = new NumericalSequence(maxSquare); int[] array = sequence.ToArray(); Assert.Equal(expected, array); }
static void Main(string[] args) { long numberSequenceStart = long.Parse(args[0]); long numberSequenceFinish = long.Parse(args[1]); NumericalSequence sequence = new NumericalSequence(numberSequenceStart, numberSequenceFinish); foreach (long item in sequence) { Console.Write($"{item}, "); } Console.ReadKey(); }
static void Main(string[] args) { NumericalSequence c = new NumericalSequence(); object o = c.makePalindrome(new int[] { 3, 23, 21, 23, 42, 39, 63, 76, 13, 13, 13, 32, 12, 42, 26 }); if (o is IEnumerable) { foreach (object b in (IEnumerable)o) { System.Console.Out.WriteLine(b); } } else System.Console.Out.WriteLine(o); System.Console.In.ReadLine(); }
public void NumericalSequence_WithMinAndMaxSquareLessThanZero_ShouldThrowArgumentOutOfRangeException(int minSquare, int maxSquare) { NumericalSequence sequence; Assert.Throws <ArgumentOutOfRangeException>(() => sequence = new NumericalSequence(minSquare, maxSquare)); }