public IEnumerator <object[]> GetEnumerator() { yield return(new object[] { new User { FirstName = null, LastName = null, ProfilePictureUrl = GenerateRandom.String(), Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = GenerateRandom.String() } }); yield return(new object[] { new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = GenerateRandom.String(), Email = GenerateRandom.String(), PhoneNumber = GenerateRandom.String(), BirthDate = GenerateRandom.DateTime(), Status = GenerateRandom.String() } }); }
public void GenerateRandom_AllRandomNumbersAreDifferent() { var rd = new GenerateRandom(1, 10, 4); List <int> rdList = rd.RandomNumberList(); Assert.IsTrue(rdList[0] != rdList[1] && rdList[0] != rdList[2] && rdList[0] != rdList[3] && rdList[1] != rdList[2] && rdList[1] != rdList[3] && rdList[2] != rdList[3]); }
public static void Result() { Console.WriteLine($"Your Character is a {GenerateRandom.Random(CharacterDataLists.occupations)}." + $"\nThey are located in {GenerateRandom.Random(CharacterDataLists.locations)}." + $"\nTheir item of interest is a {GenerateRandom.Random(CharacterDataLists.items)}." + $"\nThey are motivated by {GenerateRandom.Random(CharacterDataLists.motives)}"); }
private static void PerformAction(int num) { switch (num) { case 1: var rest1 = new GenerateQuick(Program.user1); rest1.PerformAction(1); break; case 2: var rest2 = new GenerateRandom(); rest2.ShowResult(); break; case 3: var rest3 = new GeneratePassword(); rest3.ShowResult(); break; case 4: ExitApp(); break; default: Thread.Sleep(2000); System.Console.WriteLine("You've given wrong number..."); break; } }
static void Main(string[] args) { GenerateRandom[] arrOfDel = new GenerateRandom[10]; GetAverage getAverage = delegate(GenerateRandom[] generateRans) { int sum = 0; for (int i = 0; i < generateRans.Length; i++) { sum += generateRans[i].Invoke(); } return((double)sum / (double)generateRans.Length); }; GenerateRandom generator = delegate() { Random rnd = new Random(); return(rnd.Next(100)); }; for (int j = 0; j < 10; j++) { arrOfDel[j] = generator; } ; Console.WriteLine($"Result - {getAverage(arrOfDel):f2}"); }
public void GenerateRandom_CorrectNumberOfRandomNumbersGenerated() { var rd = new GenerateRandom(1, 10, 4); List <int> rdList = rd.RandomNumberList(); Assert.IsTrue(rdList.Count == 4); }
public NewUser(DMIUser dmiuser) { this.firstName = (dmiuser.firstname != null) ? dmiuser.firstname : GenerateRandom.StringOfLength(5); this.lastName = (dmiuser.lastname != null) ? dmiuser.lastname : GenerateRandom.StringOfLength(5); this.username = (dmiuser.username != null) ? dmiuser.username : GenerateRandom.StringOfLength(5); this.password = (dmiuser.password != null) ? dmiuser.password : "******"; this.email = (dmiuser.email != null) ? dmiuser.email : Config.Environment.Email; }
public void CheckIfUGenearatesLentghOf2() { var tempGenerator = new GenerateRandom(); var x = tempGenerator.GetSequenceOf2(); Console.WriteLine(x); Assert.Equal(2, x.Length); }
static void Main(string[] args) { GenerateRandom rand = new GenerateRandom(10); for (int i = 0; i < 25; i++) { Console.WriteLine(rand.nextInt()); } }
public void SetHearingDetails() { _c.Test.HearingDetails.CaseNumber = $"{GenerateRandom.CaseNumber(_fromRandomNumber)}"; _browsers[_c.CurrentUser].Clear(HearingDetailsPage.CaseNumberTextfield); _browsers[_c.CurrentUser].Driver.WaitUntilVisible(HearingDetailsPage.CaseNumberTextfield).SendKeys(_c.Test.HearingDetails.CaseNumber); _browsers[_c.CurrentUser].Driver.WaitUntilTextPresent(HearingDetailsPage.CaseNumberTextfield, _c.Test.HearingDetails.CaseNumber); _c.Test.HearingDetails.CaseName = $"Admin Web Automated Test {GenerateRandom.Letters(_fromRandomNumber)}"; _browsers[_c.CurrentUser].Clear(HearingDetailsPage.CaseNameTextfield); _browsers[_c.CurrentUser].Driver.WaitUntilVisible(HearingDetailsPage.CaseNameTextfield).SendKeys(_c.Test.HearingDetails.CaseName); _browsers[_c.CurrentUser].Driver.WaitUntilTextPresent(HearingDetailsPage.CaseNameTextfield, _c.Test.HearingDetails.CaseName); }
IEnumerator SpawnInstantLose() { yield return(new WaitForSeconds(Random.Range(6f, 18f))); while (true) { float xPos = GenerateRandom.genRandom(-2.5, 2.5); Instantiate(InstantLose, new Vector2(xPos, 5.5f), Quaternion.identity); yield return(new WaitForSeconds(Random.Range(2f, 24f))); } }
IEnumerator SpawnDebuff() { yield return(new WaitForSeconds(6f)); while (true) { float xPos = GenerateRandom.genRandom(-2.5, 2.5); Instantiate(TargetDebuff, new Vector2(xPos, 5.5f), Quaternion.identity); yield return(new WaitForSeconds(GenerateRandom.genRandom(Random.Range(lowEdgeDeb, highEdgeDeb), Random.Range(lowEdgeDeb, highEdgeDeb)))); } }
IEnumerator SpawnNegative() { yield return(new WaitForSeconds(5f)); while (true) { float xPos = GenerateRandom.genRandom(-2.5, 2.5); Instantiate(TargetNegative, new Vector2(xPos, 5.5f), Quaternion.identity); yield return(new WaitForSeconds(Random.Range(lowEdgeNeg, highEdgeNeg))); } }
private void AddCases() { var caseRequest = new CaseRequest { Name = GenerateRandomCaseName(), Number = GenerateRandom.CaseNumber(_randomNumber), IsLeadCase = HearingData.IS_LEAD_CASE }; _request.Cases.Add(caseRequest); }
public static NewUser GenerateUserWithUsername(string username) { NewUser newuser = new NewUser(); newuser.email = Config.Environment.Email; newuser.username = username; newuser.firstName = GenerateRandom.StringOfLength(5); newuser.lastName = GenerateRandom.StringOfLength(5); newuser.password = "******"; return(newuser); }
public static NewUser GenerateRandomUser() { NewUser newuser = new NewUser(); newuser.email = "*****@*****.**"; newuser.username = "******" + GenerateRandom.StringOfLength(8); newuser.firstName = GenerateRandom.StringOfLength(5); newuser.lastName = GenerateRandom.StringOfLength(5); newuser.password = "******"; return(newuser); }
public BookNewConferenceRequest BuildRequest() { _request.AudioRecordingRequired = HearingData.AUDIO_RECORDING_REQUIRED; _request.CaseName = $"{AppShortName.FromApplication(Application.TestApi)} {GetCaseNamePrefix()} {GenerateRandom.Letters(_randomNumber)}"; _request.CaseNumber = GenerateRandom.CaseNumber(_randomNumber); _request.Endpoints = new List <AddEndpointRequest>(); _request.HearingRefId = Guid.NewGuid(); _request.HearingVenueName = HearingData.VENUE_NAME; _request.Participants = new BookConferenceParticipantsBuilder(_users, _isCACDCaseType).Build(); _request.ScheduledDateTime = DateTime.UtcNow.AddMinutes(5); _request.ScheduledDuration = HearingData.SCHEDULED_DURATION; AddLinkedParticipants(); return(_request); }
public void SaveItemDocument() { foreach (DocumentModel document in SelectedFiles) { string fileExtension = ".jpg"; string newName = GenerateRandom.RandomString(8) + fileExtension; var newDocument = new DocumentModel(); newDocument.Name = newName + fileExtension; string baseDirectory = @"C:\Users\jwhit\Documents\RobinBradley2021SavedDocuments\EquipmentDocuments\"; string fullPath = Path.Combine(baseDirectory, newName); System.IO.File.Copy(document.Name, fullPath); Documents.Add(newDocument); } }
public BookNewHearingRequest Build() { AddParticipants(); _request.Cases = new List <CaseRequest>() { new CaseRequest() { IsLeadCase = HearingData.IS_LEAD_CASE, Name = $"BQS {HearingData.AUTOMATED_CASE_NAME_PREFIX} {GenerateRandom.Letters(_randomNumber)}", Number = GenerateRandom.CaseNumber(_randomNumber) } }; return(_request); }
public BookNewConferenceRequestBuilder(string caseName) { var fromRandomNumber = new Random(); _bookNewConferenceRequest = Builder <BookNewConferenceRequest> .CreateNew() .With(x => x.HearingRefId = Guid.NewGuid()) .With(x => x.CaseType = "Civil Money Claims") .With(x => x.ScheduledDateTime = DateTime.Now.ToLocalTime().AddMinutes(2)) .With(x => x.CaseNumber = $"{GenerateRandom.CaseNumber(fromRandomNumber)}") .With(x => x.CaseName = $"{caseName} {GenerateRandom.Letters(fromRandomNumber)}") .With(x => x.ScheduledDuration = 120) .With(x => x.Participants = new List <ParticipantRequest>()) .With(x => x.AudioRecordingRequired = false) .With(x => x.Endpoints = new List <AddEndpointRequest>()) .Build(); }
public void BiomeGenerate() { GetHighestPositon(); int highestPositon = elevationList.IndexOf(maxPosition); grid.cells[highestPositon].visible = true; sttg.SetTileToCell(sttg.collection.spriteCollection[1], grid.CellGetPosition(highestPositon), grid.cells[highestPositon]); for (int i = 0; i < elevationList.Count; i++) { if (elevationList[i] < waterLevel) { //海拔低于海平面且单元格信息为null // water grid.cells[i].visible = false; sttg.SetTileToCell(sttg.collection.spriteCollection[4], grid.CellGetPosition(i), grid.cells[i]); } else if (elevationList[i] > waterLevel && grid.cells[i].info == null) { //海拔高于海平面且单元格信息为null if (GenerateRandom.floatRandom(0.6f, Random.Range(0, 1f))) { grid.cells[i].visible = true; sttg.SetTileToCell(sttg.collection.spriteCollection[6], grid.CellGetPosition(i), grid.cells[i]); } else { grid.cells[i].visible = true; sttg.SetTileToCell(sttg.collection.spriteCollection[0], grid.CellGetPosition(i), grid.cells[i]); } } else if (elevationList[i] > waterLevel && grid.cells[i].info != null) { Debug.Log("Is City"); //海报高于海平面且单元格信息不为null } else if (elevationList[i] == waterLevel) { grid.cells[i].visible = true; sttg.SetTileToCell(sttg.collection.spriteCollection[0], grid.CellGetPosition(i), grid.cells[i]); } } }
public void RegisterAccount() { createAccount.SignIn(); GenerateRandom generateRandom = new GenerateRandom(); account = new Account(); account.Email = GenerateRandom.RandomEmail(); account.FirstName = GenerateRandom.RandomName(); account.LastName = GenerateRandom.RandomLastName(); account.Password = GenerateRandom.RandomPassword(); account.Address = GenerateRandom.RandomString(6, false); account.PostalCode = "00000"; account.Alias = "Ninguna"; account.Country = "United States"; account.State = GenerateRandom.RandomState(); account.City = "Lima"; account.Phone = GenerateRandom.RandomPhone(9); createAccount.CreateAccount(account); }
public ConferenceBuilder(bool ignoreId = false, Guid?knownHearingRefId = null, DateTime?scheduledDateTime = null, string venueName = "MyVenue") { _builderSettings = new BuilderSettings(); if (ignoreId) { _builderSettings.DisablePropertyNamingFor <Participant, long?>(x => x.TestCallResultId); _builderSettings.DisablePropertyNamingFor <ParticipantStatus, long>(x => x.Id); _builderSettings.DisablePropertyNamingFor <ConferenceStatus, long>(x => x.Id); _builderSettings.DisablePropertyNamingFor <Task, long>(x => x.Id); } var hearingRefId = knownHearingRefId ?? Guid.NewGuid(); var scheduleDateTime = scheduledDateTime ?? DateTime.UtcNow.AddMinutes(30); const string caseType = "Civil Money Claims"; var caseNumber = $"{GenerateRandom.CaseNumber(new Random())}"; const string caseName = CaseName; const int scheduledDuration = 120; _conference = new Conference(hearingRefId, caseType, scheduleDateTime, caseNumber, caseName, scheduledDuration, venueName, false, string.Empty); }
public static void Generate(List <string> xpaths, string outname, long sizeoutput, long rowsize, GenerateType type, int writersCount, GenerateRandom genrand) { int RecordLength = -1; if (outname.StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) { outname = outname.Substring(6); } { int iat = outname.IndexOf('@'); if (-1 != iat) { try { RecordLength = Surrogate.GetRecordSize(outname.Substring(iat + 1)); } catch (Exception e) { Console.Error.WriteLine(e.Message); SetFailure(); return; } outname = outname.Substring(0, iat); } } string reason = ""; if (dfs.IsBadFilename(outname, out reason)) { Console.Error.WriteLine("Invalid output-dfsfile: {0}", reason); SetFailure(); return; } dfs dc = LoadDfsConfig(); if (null != DfsFindAny(dc, outname)) { Console.Error.WriteLine("Output file already exists in DFS: {0}", outname); SetFailure(); return; } if (RecordLength > 0) { if (rowsize < 0) { rowsize = RecordLength; } else { if (rowsize > RecordLength) { Console.Error.WriteLine("Row data cannot be greater than DFS record length"); SetFailure(); return; } } if (type != GenerateType.BINARY) { Console.Error.WriteLine("Error: must specify type=bin when generating a rectangular binary DFS file"); SetFailure(); return; } } else { if (rowsize < 1) { rowsize = 100; } } string tempfnpost = "." + Guid.NewGuid().ToString() + "." + System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string jobsfn = "gen-jobs.xml" + tempfnpost; string rnd = ""; string nextrandBin = ""; string nextrandAscii = ""; string nextrandLen = ""; string nextrandLower = ""; string nextrandUpper = ""; if (genrand == GenerateRandom.RANDOM) { rnd = "Random rnd = new Random(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "rnd.Next(3, 9 + 1)"; nextrandLower = "rnd.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "rnd.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.FRANDOM) { rnd = "FRandom.Seed(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "FRandom.Next()"; nextrandAscii = "FRandom.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "FRandom.Next(3, 9 + 1)"; nextrandLower = "FRandom.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "FRandom.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.DRANDOM) { if (GenerateType.ASCII == type) { rnd = @"DRandom rnd = new DRandom(false, true, (int)' ' + 1, (int)'~' + 1); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; nextrandBin = "rnd.Next()"; } else if (GenerateType.WORDS == type) { rnd = @"DRandom rndLen = new DRandom(false, true, 3, 9 + 1); DRandom rndLower = new DRandom(false, true, (int)'a', (int)'z' + 1); DRandom rndUpper = new DRandom(false, true, (int)'A', (int)'Z' + 1); DRandom rnd = null;"; } else { rnd = @"DRandom rnd = new DRandom(); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; } nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next()"; nextrandLen = "rndLen.Next()"; nextrandLower = "rndLower.Next()"; nextrandUpper = "rndUpper.Next()"; } try { string dline = ""; string drline = ""; #if DEBUG dline = "#line 1 \"GEN.ds\"" + Environment.NewLine; drline = "#line default" + Environment.NewLine; #endif string outsuffix = ""; if (RecordLength > 0) { outsuffix = "@" + RecordLength; } string[] slaves = dc.Slaves.SlaveList.Split(';'); int maxWriters = (writersCount > 0) ? writersCount : Surrogate.NumberOfProcessors * slaves.Length; using (System.IO.StreamWriter sw = System.IO.File.CreateText(jobsfn)) { sw.Write(@"<SourceCode> <Jobs> <Job> <Narrative> <Name>Generate Data</Name> <Custodian></Custodian> <email></email> </Narrative> <IOSettings> <JobType>remote</JobType>"); for (int si = 0; si < maxWriters; si++) { sw.WriteLine(@" <DFS_IO> <DFSReader></DFSReader> <DFSWriter>dfs://" + outname + ".gen" + si.ToString() + tempfnpost + outsuffix + @"</DFSWriter> </DFS_IO>"); } sw.WriteLine((@" </IOSettings> <Remote> <![CDATA[ " + dline + @" public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput) { const bool IS_RBIN_FILE = " + ((RecordLength > 0) ? "true" : "false") + @"; // Is rectangular binary output file? const bool IS_ASCII = " + ((GenerateType.ASCII == type) ? "true" : "false") + @"; const bool IS_WORDS = " + ((GenerateType.WORDS == type) ? "true" : "false") + @"; const long size = " + sizeoutput.ToString() + @"; const long rowsize = " + rowsize.ToString() + @"; long fullrecordsize = rowsize + " + Environment.NewLine.Length + @"; if(IS_RBIN_FILE) { fullrecordsize = Qizmt_OutputRecordLength; } long numrows = size / fullrecordsize; if((size % fullrecordsize) != 0) { numrows++; } " + rnd + @" List<byte> onerow = new List<byte>((rowsize > 16777216) ? 16777216 : (int)rowsize); long numrowsPART = numrows / DSpace_BlocksTotalCount; if(IS_RBIN_FILE) { if(DSpace_BlockID < (numrows % DSpace_BlocksTotalCount)) { numrowsPART++; } } else { if(0 == DSpace_BlockID) { numrowsPART += numrows % DSpace_BlocksTotalCount; } } for(long rn = 0; rn < numrowsPART; rn++) { onerow.Clear(); byte b; if(IS_WORDS) { bool fupper = true; long remain = rowsize - 1; // Don't count trailing dot. while(remain - 1 >= 3) // -1 here for word separator space. { if(onerow.Count > 0) { onerow.Add((byte)' '); remain--; } long wlen = " + nextrandLen + @"; if(wlen > remain - 1) { wlen = remain - 1; } for(int wi = 0; wi < wlen; wi++) { if(fupper) { fupper = false; b = (byte)" + nextrandUpper + @"; } else { b = (byte)" + nextrandLower + @"; } onerow.Add(b); } remain -= wlen; } onerow.Add((byte)'.'); // Don't count trailing dot. while(remain > 0) { onerow.Add((byte)' '); remain--; } } else { for(int nb = 0; nb < rowsize; nb++) { if(IS_ASCII) { b = (byte)" + nextrandAscii + @"; } else // Binary. { for(;;) { b = (byte)" + nextrandBin + @"; if(!IS_RBIN_FILE) { if(b == 0 || b == '\n' || b == '\r') { continue; } } break; } } onerow.Add(b); } } if(IS_RBIN_FILE) { while(onerow.Count < DSpace_OutputRecordLength) { if(IS_ASCII || IS_WORDS) { //onerow.Add((byte)' '); throw new NotImplementedException(); } else { onerow.Add((byte)0); } } dfsoutput.WriteRecord(onerow); } else { dfsoutput.WriteLine(onerow); } } } " + drline + @" ]]> </Remote> </Job> </Jobs> </SourceCode> ").Replace("`", "\"")); /* * //dfsoutput.Write(onerow); * //dfsoutput.Write(`" + rowsep.Replace("\\", "\\\\").Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\"") + @"`); * */ } { // File jobsfn exists. Console.WriteLine("Generating data..."); Exec("", LoadConfig(xpaths, jobsfn), new string[] { }, false, false); if (null != DfsFindAny(dc, outname)) { SetFailure(); return; } Shell("DSpace -dfs combine \"dfs://" + outname + ".gen*" + tempfnpost + "\" + \"" + outname + "\""); if (RecordLength > 0) { Console.WriteLine("Done; file '{0}' written into DFS with {1} of random data per {2} record", outname, GetFriendlyByteSize(rowsize), GetFriendlyByteSize(RecordLength)); } else { Console.WriteLine("Done; file '{0}' written into DFS with {1} rows", outname, GetFriendlyByteSize(rowsize)); } } } finally { try { System.IO.File.Delete(jobsfn); } catch { } } }
public static void Generate(List<string> xpaths, string outname, long sizeoutput, long rowsize, GenerateType type, int writersCount, GenerateRandom genrand) { int RecordLength = -1; if (outname.StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) { outname = outname.Substring(6); } { int iat = outname.IndexOf('@'); if (-1 != iat) { try { RecordLength = Surrogate.GetRecordSize(outname.Substring(iat + 1)); } catch (Exception e) { Console.Error.WriteLine(e.Message); SetFailure(); return; } outname = outname.Substring(0, iat); } } string reason = ""; if (dfs.IsBadFilename(outname, out reason)) { Console.Error.WriteLine("Invalid output-dfsfile: {0}", reason); SetFailure(); return; } dfs dc = LoadDfsConfig(); if (null != DfsFindAny(dc, outname)) { Console.Error.WriteLine("Output file already exists in DFS: {0}", outname); SetFailure(); return; } if (RecordLength > 0) { if (rowsize < 0) { rowsize = RecordLength; } else { if (rowsize > RecordLength) { Console.Error.WriteLine("Row data cannot be greater than DFS record length"); SetFailure(); return; } } if (type != GenerateType.BINARY) { Console.Error.WriteLine("Error: must specify type=bin when generating a rectangular binary DFS file"); SetFailure(); return; } } else { if (rowsize < 1) { rowsize = 100; } } string tempfnpost = "." + Guid.NewGuid().ToString() + "." + System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string jobsfn = "gen-jobs.xml" + tempfnpost; string rnd = ""; string nextrandBin = ""; string nextrandAscii = ""; string nextrandLen = ""; string nextrandLower = ""; string nextrandUpper = ""; if (genrand == GenerateRandom.RANDOM) { rnd = "Random rnd = new Random(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "rnd.Next(3, 9 + 1)"; nextrandLower = "rnd.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "rnd.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.FRANDOM) { rnd = "FRandom.Seed(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "FRandom.Next()"; nextrandAscii = "FRandom.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "FRandom.Next(3, 9 + 1)"; nextrandLower = "FRandom.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "FRandom.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.DRANDOM) { if (GenerateType.ASCII == type) { rnd = @"DRandom rnd = new DRandom(false, true, (int)' ' + 1, (int)'~' + 1); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; nextrandBin = "rnd.Next()"; } else if (GenerateType.WORDS == type) { rnd = @"DRandom rndLen = new DRandom(false, true, 3, 9 + 1); DRandom rndLower = new DRandom(false, true, (int)'a', (int)'z' + 1); DRandom rndUpper = new DRandom(false, true, (int)'A', (int)'Z' + 1); DRandom rnd = null;"; } else { rnd = @"DRandom rnd = new DRandom(); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; } nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next()"; nextrandLen = "rndLen.Next()"; nextrandLower = "rndLower.Next()"; nextrandUpper = "rndUpper.Next()"; } try { string dline = ""; string drline = ""; #if DEBUG dline = "#line 1 \"GEN.ds\"" + Environment.NewLine; drline = "#line default" + Environment.NewLine; #endif string outsuffix = ""; if (RecordLength > 0) { outsuffix = "@" + RecordLength; } string[] slaves = dc.Slaves.SlaveList.Split(';'); int maxWriters = (writersCount > 0) ? writersCount : Surrogate.NumberOfProcessors * slaves.Length; using (System.IO.StreamWriter sw = System.IO.File.CreateText(jobsfn)) { sw.Write(@"<SourceCode> <Jobs> <Job> <Narrative> <Name>Generate Data</Name> <Custodian></Custodian> <email></email> </Narrative> <IOSettings> <JobType>remote</JobType>"); for (int si = 0; si < maxWriters; si++) { sw.WriteLine(@" <DFS_IO> <DFSReader></DFSReader> <DFSWriter>dfs://" + outname + ".gen" + si.ToString() + tempfnpost + outsuffix + @"</DFSWriter> </DFS_IO>"); } sw.WriteLine((@" </IOSettings> <Remote> <![CDATA[ " + dline + @" public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput) { const bool IS_RBIN_FILE = " + ((RecordLength > 0) ? "true" : "false") + @"; // Is rectangular binary output file? const bool IS_ASCII = " + ((GenerateType.ASCII == type) ? "true" : "false") + @"; const bool IS_WORDS = " + ((GenerateType.WORDS == type) ? "true" : "false") + @"; const long size = " + sizeoutput.ToString() + @"; const long rowsize = " + rowsize.ToString() + @"; long fullrecordsize = rowsize + " + Environment.NewLine.Length + @"; if(IS_RBIN_FILE) { fullrecordsize = Qizmt_OutputRecordLength; } long numrows = size / fullrecordsize; if((size % fullrecordsize) != 0) { numrows++; } " + rnd + @" List<byte> onerow = new List<byte>((rowsize > 16777216) ? 16777216 : (int)rowsize); long numrowsPART = numrows / DSpace_BlocksTotalCount; if(IS_RBIN_FILE) { if(DSpace_BlockID < (numrows % DSpace_BlocksTotalCount)) { numrowsPART++; } } else { if(0 == DSpace_BlockID) { numrowsPART += numrows % DSpace_BlocksTotalCount; } } for(long rn = 0; rn < numrowsPART; rn++) { onerow.Clear(); byte b; if(IS_WORDS) { bool fupper = true; long remain = rowsize - 1; // Don't count trailing dot. while(remain - 1 >= 3) // -1 here for word separator space. { if(onerow.Count > 0) { onerow.Add((byte)' '); remain--; } long wlen = " + nextrandLen + @"; if(wlen > remain - 1) { wlen = remain - 1; } for(int wi = 0; wi < wlen; wi++) { if(fupper) { fupper = false; b = (byte)" + nextrandUpper + @"; } else { b = (byte)" + nextrandLower + @"; } onerow.Add(b); } remain -= wlen; } onerow.Add((byte)'.'); // Don't count trailing dot. while(remain > 0) { onerow.Add((byte)' '); remain--; } } else { for(int nb = 0; nb < rowsize; nb++) { if(IS_ASCII) { b = (byte)" + nextrandAscii + @"; } else // Binary. { for(;;) { b = (byte)" + nextrandBin + @"; if(!IS_RBIN_FILE) { if(b == 0 || b == '\n' || b == '\r') { continue; } } break; } } onerow.Add(b); } } if(IS_RBIN_FILE) { while(onerow.Count < DSpace_OutputRecordLength) { if(IS_ASCII || IS_WORDS) { //onerow.Add((byte)' '); throw new NotImplementedException(); } else { onerow.Add((byte)0); } } dfsoutput.WriteRecord(onerow); } else { dfsoutput.WriteLine(onerow); } } } " + drline + @" ]]> </Remote> </Job> </Jobs> </SourceCode> ").Replace("`", "\"")); /* //dfsoutput.Write(onerow); //dfsoutput.Write(`" + rowsep.Replace("\\", "\\\\").Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\"") + @"`); * */ } { // File jobsfn exists. Console.WriteLine("Generating data..."); Exec("", LoadConfig(xpaths, jobsfn), new string[] { }, false, false); if (null != DfsFindAny(dc, outname)) { SetFailure(); return; } Shell("DSpace -dfs combine \"dfs://" + outname + ".gen*" + tempfnpost + "\" + \"" + outname + "\""); if (RecordLength > 0) { Console.WriteLine("Done; file '{0}' written into DFS with {1} of random data per {2} record", outname, GetFriendlyByteSize(rowsize), GetFriendlyByteSize(RecordLength)); } else { Console.WriteLine("Done; file '{0}' written into DFS with {1} rows", outname, GetFriendlyByteSize(rowsize)); } } } finally { try { System.IO.File.Delete(jobsfn); } catch { } } }
public void GenerateRandom_InvalidRangeOfNumberOfRandomNumbersParameter_ThrowsException() { var rd = new GenerateRandom(1, 10, 20); }
public void GenerateRandom_InvalidMaximumParameter_ThrowsException() { var rd = new GenerateRandom(1, -1, 1); }
public IEnumerator <object[]> GetEnumerator() { string target = GenerateRandom.Email(); yield return(new object[] { new List <User> { new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = target, PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null } }, target }); target = GenerateRandom.Email(); yield return(new object[] { new List <User> { new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = target, PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null }, new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null }, new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null } }, target }); }
public IEnumerator <object[]> GetEnumerator() { yield return(new object[] { new List <User> { new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null } }, new List <int> { 1 } }); yield return(new object[] { new List <User> { new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null }, new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null }, new User { FirstName = GenerateRandom.String(), LastName = GenerateRandom.String(), ProfilePictureUrl = null, Email = GenerateRandom.Email(), PhoneNumber = GenerateRandom.PhoneNumber(), BirthDate = GenerateRandom.DateTime(), Status = null } }, new List <int> { GenerateRandom.Int(1, 3), GenerateRandom.Int(1, 3) } }); }
public ValuesController(IHubContext <ValuesHub> hub, IHostedService hostedService) { _hostedService = hostedService as GenerateRandom; }
private string GenerateRandomCaseName() { return ($"{GetCustomCaseNamePrefix()}{GetAppShortName()}{GetCaseNamePrefix()} {GenerateRandom.Letters(_randomNumber)}"); }