//properties //methods /// <summary> /// Creates a DataTable containing a set of random boolean values. /// </summary> /// <param name="numRows">Num of rows with boolean values to generate.</param> /// <param name="dataRequest">RandomBooleanDataRequest object contains the definition for how to generate the random booleans.</param> /// <returns>ADO.NET DataTable containing the set of random values.</returns> public DataTable CreateRandomDataTable(int numRows, RandomBooleanDataRequest dataRequest) { DataTable dt = null; enRandomNumberType randNumberType = enRandomNumberType.enUnknown; if (dataRequest.BooleanOutput) { dt = CreateBooleanDataTable(numRows, dataRequest.PercentOutputValuesAsTrue.ToString(), dataRequest.PercentOutputValuesAsFalse.ToString()); } else if (dataRequest.NumericOutput) { randNumberType = GetRandomNumberType(dataRequest); if (randNumberType != enRandomNumberType.enUnknown) { dt = CreateNumericDataTable(numRows, dataRequest.PercentOutputValuesAsTrue.ToString(), dataRequest.PercentOutputValuesAsFalse.ToString(), randNumberType, dataRequest.NumericTrueValue, dataRequest.NumericFalseValue); } } else if (dataRequest.StringOutput) { dt = CreateStringDataTable(numRows, dataRequest.PercentOutputValuesAsTrue.ToString(), dataRequest.PercentOutputValuesAsFalse.ToString(), dataRequest.StringTrueValue, dataRequest.StringFalseValue); } else { dt = new DataTable(); } return(dt); }
/// <summary> /// Retrieve the type of number to generate if output request is for a numeric boolean (e.g. 0 or 1). /// </summary> /// <param name="dataRequest">RandomBooleanDataRequest objects contains the definition for how to generate the random booleans.</param> /// <returns>enRandomNumberType enum value.</returns> private enRandomNumberType GetRandomNumberType(RandomBooleanDataRequest dataRequest) { enRandomNumberType randNumType = enRandomNumberType.enUnknown; if (dataRequest.OutputIntegerValue) { if (dataRequest.Output64bitInteger) { if (dataRequest.OutputSignedInteger) { randNumType = enRandomNumberType.enLong; } else { randNumType = enRandomNumberType.enULong; } } else if (dataRequest.Output32bitInteger) { if (dataRequest.OutputSignedInteger) { randNumType = enRandomNumberType.enInt; } else { randNumType = enRandomNumberType.enUInt; } } else if (dataRequest.Output16bitInteger) { if (dataRequest.OutputSignedInteger) { randNumType = enRandomNumberType.enShort; } else { randNumType = enRandomNumberType.enUShort; } } else if (dataRequest.Output8bitInteger) { if (dataRequest.OutputSignedInteger) { randNumType = enRandomNumberType.enSByte; } else { randNumType = enRandomNumberType.enByte; } } else { randNumType = enRandomNumberType.enUnknown; } } else if (dataRequest.OutputDoubleValue) { randNumType = enRandomNumberType.enDouble; } else if (dataRequest.OutputFloatValue) { randNumType = enRandomNumberType.enFloat; } else if (dataRequest.OutputDecimalValue) { randNumType = enRandomNumberType.enDecimal; } else { randNumType = enRandomNumberType.enUnknown; } return(randNumType); }