public DateTime GetFuture(int yearSpan) { DateTime now = DateTime.Now; long timespan = RandomProxy.Next(1000, (long)yearSpan * 365 * 24 * 3600 * 1000); TimeSpan span = new TimeSpan(timespan); return(now.Add(span)); }
public string GetSentence(int wordCount, int range) { var resultList = GetWords(wordCount + RandomProxy.Next(range)); var charList = resultList.ToCharArray(); charList[0] = char.ToUpper(charList[0]); return(new string(charList) + "."); }
public DateTime GetRecent(int daySpan) { DateTime now = DateTime.Now; long timespan = RandomProxy.Next(1000, (long)daySpan * 24 * 3600 * 1000); TimeSpan span = new TimeSpan(timespan); return(now.Add(span)); }
public void TestRandomSelection() { int i = RandomProxy.Next(); DummyClass d = new DummyClass(i); var r = new RandomFactory(d, LocaleType.en); var result = r.GetRandomItemFromProperty <int>("Test1", d); Assert.IsTrue(Array.Exists(d.Test1, n => n == result)); }
public virtual string GetFirstName() { if (locale.FemaleFirstName != null && locale.MaleFirstName != null) { if (RandomProxy.NextBool()) { return(Selector.GetRandomItemFromList(locale.FemaleFirstName)); } return(Selector.GetRandomItemFromList(locale.MaleFirstName)); } return(Selector.GetRandomItemFromList(locale.FirstName)); }
public void TestNextMethod2() { int m = RandomProxy.Next(2, 100); DummyClass d = new DummyClass(m); string format = @"#{Test1} #{Test1}"; var r = new RandomFactory(d, LocaleType.en); var result = r.Next <int>(format); string[] numbers = result.Split(' '); Assert.AreEqual(numbers.Length, 2); Assert.IsTrue(Array.Exists(d.Test1, n => n == int.Parse(numbers[0]))); Assert.IsTrue(Array.Exists(d.Test1, n => n == int.Parse(numbers[0]))); Assert.IsTrue(numbers[0] != numbers[1]); }
public void TestRandomFillin() { int m = RandomProxy.Next(); DummyClass d = new DummyClass(m); string format = @"#{Test1} #{Test2}"; var r = new RandomFactory(d, LocaleType.en); for (int i = 0; i < 100000; i++) { var result = r.FillInRandomData <int>(format, d); string[] numbers = result.Split(' '); Assert.AreEqual(numbers.Length, 2); Assert.IsTrue(Array.Exists(d.Test1, n => n == int.Parse(numbers[0]))); Assert.IsTrue(Array.Exists(d.Test2, n => n == int.Parse(numbers[1]))); } }
public virtual string GetUserName(string firstName, string lastName) { switch (RandomProxy.Next(3)) { case 0: return(firstName + RandomProxy.Next(100)); case 1: return(string.Format("{0}{1}{2}", firstName, Selector.GetRandomItemFromList(new[] { ".", "_" }), lastName)); default: return(string.Format("{0}{1}{2}{3}", firstName, Selector.GetRandomItemFromList(new[] { ".", "_" }), lastName, RandomProxy.Next(100))); } }
public static void Main(string[] args) { int numberOfQueries = int.Parse(Console.ReadLine()); using (StreamWriter log = new StreamWriter("/Users/MarinaRoshupkina/Projects/2020-2021/module2/YC7/TaskJ/log.txt")) { RandomProxy random = new RandomProxy(log); for (int i = 0; i < numberOfQueries; i++) { string[] comands = Console.ReadLine().Split(); try { if (comands[0] == "register") { random.Register(comands[1], int.Parse(comands[2])); continue; } switch (comands.Length) { case 2: random.Next(comands[1]); break; case 3: random.Next(comands[1], int.Parse(comands[2])); break; case 4: random.Next(comands[1], int.Parse(comands[2]), int.Parse(comands[3])); break; } } catch (ArgumentException ex) { log.WriteLine($"{ex.GetType()} {ex.Message}"); } } } }
public string GetAmount(decimal min, decimal max, int decimalPlace, string symbol) { return(symbol + Decimal.Round(RandomProxy.Next(min, max), decimalPlace)); }
public DateTime GetDateBetween(DateTime from, DateTime to) { var timeSpan = to - from; return(from.Add(new TimeSpan((long)RandomProxy.NextDouble(timeSpan.TotalMilliseconds)))); }
public Single GetLongitute() { return(RandomProxy.NextSingle() * 180 - 90); }
public Single GetLatitude() { return(RandomProxy.NextSingle() * 180 - 90); }
public string GetParagraph(int count) { return(this.GetSentences(count + RandomProxy.Next(4))); }
private string randInt(int minValue, int maxValue) { return(RandomProxy.Next(minValue, maxValue).ToString()); }
public virtual string GetIP() { return(string.Format("{0}.{1}.{2}.{3}", RandomProxy.Next(256), RandomProxy.Next(256), RandomProxy.Next(256), RandomProxy.Next(256))); }
private string GetUserAgent() { // Code adopted from http://www.hackforums.net/archive/index.php/thread-1568584.html // Also update some new versions string[] arrBrowsers = { "Firefox/0." + randInt(7, 9) + "." + randInt(0, 5), "Outlook-Express/" + randInt(5, 8) + "." + randInt(0, 5), "Opera/" + randInt(7, 9) + "." + randInt(1, 80), "Safari/4" + randInt(1, 15) + "." + randInt(1, 6), "Arora/0." + randInt(1, 5), "Gecko/200" + randInt(0, 9024) + "Firefox/3." + randInt(1, 6), "Lynx/2." + randInt(1, 8) + "." + randInt(2, 5) + "dev." + randInt(1,16), "Chrome/" + randInt(10, 35) + ".0." + randInt(0, 154) + "." + randInt(0, 60) }; string[] arrOS = { "Windows NT 5.1", "Windows NT 6.1", "Windows NT 6.0", "Windows NT 6.3", "Windows", "Windows 95", "Windows 98", "FreeBSD i686", "Ubuntu i686", "Macintosh", "Linux" }; string[] arrPlugins = { "MS-RTC LM " + randInt(4, 8) + ";", "Win64;", "x64;", "Trident/" + randInt(4, 6) + ".0;", "SLCC2;", ".NET CLR " + randInt(2, 4) + "." + randInt(1, 7) + ".30" + randInt(50, 500) + ";", "Media Center PC " + randInt(0, 6) + ".0;", "Tablet PC " + randInt(1, 3) + ".0;", "Presto/2." + randInt(0, 2) + "." + randInt(0, 9), "rv:1." + randInt(1, 5) + "." + randInt(1, 9) + ";", "WOW64;", "GTB" + randInt(5, 7) + ";", "WebTV/2." + randInt(0, 9) + ";", "AppleWebKit/" + randInt(500, 550) + "." + randInt(1, 50) + " (KHTML, like Gecko)", "Zune " + randInt(1, 4) + ".0;", "msn OptimizedIE" + randInt(5, 8) + ";", "OfficeLiveConnector.1." + randInt(1, 9) + ";", "OfficeLivePatch.0." + randInt(0, 5) + ";", "AskTB5." + randInt(0, 7), "MS-RTC LM " + randInt(5, 8) + ";", "InfoPath." + randInt(1, 4) + ";", ".NET" + randInt(2, 4) + ".0C;" }; string strPlugins = String.Empty; int plugincount = RandomProxy.Next(3, 6); int[] history = new int[plugincount]; for (int i = 0; i != plugincount; i++) { int ran = RandomProxy.Next(0, arrPlugins.Length); if (!history.Contains(ran)) { history[i] = ran; strPlugins = strPlugins + " " + arrPlugins[ran]; } else { i--; } } string Type = "Mozilla/" + randInt(4, 6) + ".0"; string OS = arrOS[RandomProxy.Next(0, arrOS.Length)]; string[] arrCompatible = { "compatible; MSIE " + randInt(6, 10) + ".0; ", "", "" }; string Compatible = arrCompatible[RandomProxy.Next(0, 1)]; if (OS.IndexOf("Linux") != -1 || OS.IndexOf("Ubuntu") != -1 || OS.IndexOf("FreeBSD") != -1 || OS.IndexOf("Macintosh") != -1) { Compatible = ""; } //remove the compatible MSIE message from the string return(Type + " (" + Compatible + OS + ";" + strPlugins + " " + arrBrowsers[RandomProxy.Next(0, arrBrowsers.Length)] + " )"); }
public virtual Color GetColorARGB() { return(Color.FromArgb(RandomProxy.Next(256), RandomProxy.Next(256), RandomProxy.Next(256), RandomProxy.Next(256))); }