public static InputData Parse(string[] args) { if (!BaseValidator.IsNotEmptyArgs(args)) { throw new NullReferenceException("Array of parameters is null"); //81 } if (!BaseValidator.IsCorrectLength(args , InputData.MinCountParams, InputData.MaxCountParams)) { throw new ArgumentException( "The number of parameters is incorrect. " + "There must be: " + InputData.MinCountParams + " " + "or " + InputData.MaxCountParams); } if (BaseValidator.DoesFileExist(args[0])) { throw new FileNotFoundException(); } return(new InputData { PathToFile = args[0], TargetStr = args[1], ReplaceStr = args.Length > InputData.MinCountParams ? args[2] : null, Mode = args.Length == InputData.MaxCountParams ? InputData.ProgramMode.ReplaceStr : InputData.ProgramMode.SearchStr }); }
public static InputData ParseArgs(string[] args) { if (!BaseValidator.IsNotEmptyArgs(args)) { throw new NullReferenceException("Array of parameters is null"); //81 } if (!BaseValidator.IsCorrectLength(args , InputData.MinCountParams, InputData.MaxCountParams)) { throw new ArgumentException( "The number of parameters is incorrect. " + "There must be: " + InputData.MinCountParams + " " + "or " + InputData.MaxCountParams); } if (BaseValidator.IsCorrectLength(args, InputData.MaxCountParams)) { return(new InputData { ProgramMode = InputData.Mode.Fibonacci, StartFibonacciRange = Int32.Parse(args[0]), EndFibonacciRange = Int32.Parse(args[1]), }); } else { return(new InputData { ProgramMode = InputData.Mode.Square, SquaryValue = Int32.Parse(args[0]), }); } }
public void IsNotEmptyArr_NotNull_True() { //arrange string[] arr = new string[1]; //act bool result = BaseValidator.IsNotEmptyArgs(arr); //assert Assert.True(result); }
public void IsNotEmptyArr_Null_False() { //arrange string[] arr = null; //act bool result = BaseValidator.IsNotEmptyArgs(arr); //assert Assert.False(result); }
public static InputData Parse(string[] args) { if (!BaseValidator.IsNotEmptyArgs(args)) { throw new NullReferenceException("Array of parameters is null"); //81 } if (!BaseValidator.IsCorrectLength(args, InputData.CountParams)) { throw new ArgumentException( "The number of parameters is incorrect. " + "There must be: " + InputData.CountParams); } return(new InputData { NumberOfRows = Int32.Parse(args[0]), NumberOfColumns = Int32.Parse(args[1]), }); }
public static InputData Parse(string[] args) { if (!BaseValidator.IsNotEmptyArgs(args)) { throw new NullReferenceException("Array of parameters is null"); //81 } if (!BaseValidator.IsCorrectLength(args, InputData.CountParams)) { throw new ArgumentException( "The number of parameters is incorrect. " + "There must be: " + InputData.CountParams); } return(new InputData { LengthFirst = Double.Parse(args[0]), HeightFirst = Double.Parse(args[1]), LengthSecond = Double.Parse(args[2]), HeightSecond = Double.Parse(args[3]) }); }
public static InputDTO Parse(string[] args) { if (!BaseValidator.IsNotEmptyArgs(args)) { throw new NullReferenceException("Array of parameters is null"); } if (!BaseValidator.IsCorrectLength(args, InputDTO.CountParams)) { throw new ArgumentException( "The number of parameters is incorrect. " + "There must be: " + InputDTO.CountParams); } return(new InputDTO() { Number = Int64.Parse(args[0]), Algorithm = (InputDTO.Algorithms) Enum.Parse(typeof(InputDTO.Algorithms), args[1]) }); }