public void SetOfOneThreeElements() { var generator = new IntGenerator(42, 45).Unique(); 3.Times(() => generator.GetRandomValue()); Assert.Throws <HeyITriedFiftyTimesButCouldNotGetADifferentValue>(() => generator.GetRandomValue()); }
public object GenerateValue(Type type) { Console.WriteLine(); IntGenerator intGenerator = new IntGenerator(random); return(intGenerator.GenerateValue()); }
public void TestReset() { IntGenerator generator = IntGenerator.Of(0, 31); Assert.AreEqual(0, generator.Get()); generator.MoveNext(); Assert.AreEqual(0, (int)generator.Current); Assert.AreEqual(1, generator.Get()); Assert.AreEqual(1, generator.Get()); generator.MoveNext(); Assert.AreEqual(1, (int)generator.Current); generator.MoveNext(); Assert.AreEqual(2, (int)generator.Current); Assert.AreEqual(3, generator.Get()); generator.Reset(); Assert.AreEqual(0, generator.Get()); generator.MoveNext(); Assert.AreEqual(0, (int)generator.Current); Assert.AreEqual(1, generator.Get()); Assert.AreEqual(1, generator.Get()); generator.MoveNext(); Assert.AreEqual(1, (int)generator.Current); generator.MoveNext(); Assert.AreEqual(2, (int)generator.Current); Assert.AreEqual(3, generator.Get()); }
public void Select_should_equal_Select() { IEnumerable <int> items = IntGenerator.Range(1, 12); IEnumerable <int> others = IntGenerator.Range(1, 12); Assert.Equal(items, others); }
public void SRP() { var logger = new Logger(); var guidGenerator = new GuidGenerator(logger); var intGenerator = new IntGenerator(logger); Console.WriteLine(guidGenerator.GetNewId()); Console.WriteLine(intGenerator.GetNewId()); }
internal static void Seed(BillsPaymentSystemContext context, int count, List <User> users) { for (int i = 0; i < count; i++) { var payment = new PaymentMethod() { User = users[IntGenerator.GenerateInt(0, users.Count - 1)], Type = PaymentType.BankAccount, BankAccount = new BankAccount() { BankAccountId = i, //Balance = PriceGenerator.GeneratePrice(), BankName = TextGenerator.FirstName() + "\'s Bank", SwiftCode = TextGenerator.Password(10) }, BankAccountId = i }; payment.BankAccount.Deposit(PriceGenerator.GeneratePrice()); var result = new List <ValidationResult>(); if (AttributeValidator.IsValid(payment, result)) { context.PaymentMethods.Add(payment); } else { Console.WriteLine(string.Join(Environment.NewLine, result)); } payment = new PaymentMethod() { User = users[IntGenerator.GenerateInt(0, users.Count - 1)], Type = PaymentType.CreditCard, CreditCard = new CreditCard() { CreditCardId = i, ExpirationDate = DateGenerator.FutureDate(), Limit = PriceGenerator.GeneratePrice(), //MoneyOwed = PriceGenerator.GeneratePrice() }, CreditCardId = i }; payment.CreditCard.Withdraw(PriceGenerator.GeneratePrice()); result = new List <ValidationResult>(); if (AttributeValidator.IsValid(payment, result)) { context.PaymentMethods.Add(payment); } else { Console.WriteLine(string.Join(Environment.NewLine, result)); } } context.SaveChanges(); }
public void TestCount() { IntGenerator generator = IntGenerator.Of(-4, -4); Assert.AreEqual(0, generator.Count); generator.MoveNext(); Assert.AreEqual(-4, generator.Current); generator.MoveNext(); Assert.AreEqual(-4, generator.Current); Assert.IsFalse(generator.MoveNext()); }
public void TestOf() { List <int> l = new List <int>(); l.Add(42); Generator <int> g = Generator <int> .Of(l, IntGenerator.Of(0, 1)); Assert.IsTrue(g.MoveNext()); Assert.AreEqual(42, (int)g.Current); Assert.IsFalse(g.MoveNext()); }
public unsafe void TestVectorizedUnrolled(IntGenerator generator) { var(data, stepSize, reproContext) = generator(); fixed(int *dataPtr = &data[0]) { var numNegs = CountNegatives.CountNegativesVectorizedUnrolled(dataPtr, data.Length); Assert.That(numNegs, Is.EqualTo(data.Count(i => i < 0)), reproContext); Console.WriteLine(numNegs); } }
public static void SortedDictionary_ValueCollectionTest2() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); Driver <int, int> intDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the //change is reflected int count = 100; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; int half = count / 2; SimpleRef <int>[] simpleInts_1 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half]; SimpleRef <int>[] simpleInts_2 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half]; for (int i = 0; i < count; i++) { ints[i] = i; } int[] ints_1 = new int[half]; int[] ints_2 = new int[half]; for (int i = 0; i < half; i++) { simpleInts_1[i] = simpleInts[i]; simpleStrings_1[i] = simpleStrings[i]; ints_1[i] = ints[i]; simpleInts_2[i] = simpleInts[i + half]; simpleStrings_2[i] = simpleStrings[i + half]; ints_2[i] = ints[i + half]; } intDriver.TestModify(ints_1, ints_1, ints_2); simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2); intDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2); simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2); }
internal static Homework GenerateHomework(List <Course> courses, List <Student> students) { var homework = new Homework() { Content = TextGenerator.Text("Lab", "Exercise", "Exam", "Other stuff"), SubmissionTime = DateGenerator.RandomDate(), ContentType = (ContentType)IntGenerator.GenerateInt(1, 3), Course = courses[IntGenerator.GenerateInt(0, courses.Count - 1)], Student = students[IntGenerator.GenerateInt(0, students.Count - 1)] }; return(homework); }
public void TestIntegerGenerator_SpecifyNext() { int i = 28; Generator <int> generator = IntGenerator.Of(i, 31); generator.MoveNext(); Assert.IsFalse(generator.Current == 29); generator.MoveNext(); Assert.IsTrue(generator.Current == 29); generator.MoveNext(); Assert.IsTrue(generator.Current == 30); Assert.IsFalse(generator.MoveNext()); }
public void TestIntegerGenerator() { int i = 0; Generator <int> generator = IntGenerator.Of(0, 31); foreach (int result in generator) { Assert.AreNotEqual(result, i - 1); Assert.AreNotEqual(result, i + 1); Assert.AreEqual(result, i); i++; } Assert.IsTrue(i == 31); Assert.IsFalse(i == 32); }
/// <summary> /// Gets indexes of neighborhood cells within centered radius /// </summary> /// <param name="centerIndex">The index of the point. The coordinates are expressed as a single index by /// using the dimensions as a mixed radix definition. For example, in dimensions 42x10, the point [1, 4] is index 1*420 + 4*10 = 460. /// </param> /// <param name="radius"></param> /// <param name="topology"></param> /// <returns>The points in the neighborhood, including centerIndex.</returns> public static int[] GetWrappingNeighborhood(int centerIndex, int radius, HtmModuleTopology topology) { int[] cp = HtmCompute.GetCoordinatesFromIndex(centerIndex, topology); // Dims of columns IntGenerator[] intGens = new IntGenerator[topology.Dimensions.Length]; for (int i = 0; i < topology.Dimensions.Length; i++) { intGens[i] = new IntGenerator(cp[i] - radius, Math.Min((cp[i] - radius) + topology.Dimensions[i] - 1, cp[i] + radius) + 1); } List <List <int> > result = new List <List <int> >(); result.Add(new List <int>()); List <List <int> > interim = new List <List <int> >(); int k = 0; foreach (IntGenerator gen in intGens) { interim.Clear(); interim.AddRange(result); result.Clear(); foreach (var lx in interim) { gen.Reset(); for (int y = 0; y < gen.Size(); y++) { int py = ArrayUtils.Modulo(gen.Next(), topology.Dimensions[k]); //int py = gen.next() % dimensions[k]; List <int> tl = new List <int>(); tl.AddRange(lx); tl.Add(py); result.Add(tl); } } k++; } return(result.Select((tl) => GetFlatIndexFromCoordinates(tl.ToArray(), topology)).ToArray()); }
private static StudentDto GetStudent() { var name = TextGenerator.FirstName; return(new StudentDto() { Name = name, Gender = "Male", BirthDate = DateGenerator.PastDate.ToString("yyyy'/'MM'/'dd"), PhoneNumber = IntGenerator.GenerateInt(1000000, 9999999), Email = EmailGenerator.NewEmail(name), FacultyNumber = IntGenerator.GenerateInt(1000000, 9999999), Specialty = TextGenerator.Text("C# Web Developer", "Java Web Developer", "JavaScript FrontEnd Developer"), University = "SoftUni", Exams = GetExams(1) }); }
public Expr(ICFMangleContext ctx) : base(ctx) { _invCompiled = new CilFragment(); _stateVar = new Local(ctx.Method.Module.CorLibTypes.Int32); var body = ctx.Method.Body; body.Variables.Add(_stateVar); body.InitLocals = true; var nm = new IntGenerator(ctx.Mangler.Rng, ctx.Mangler.Options.MaxMangleIterations); var codec = nm.Generate(); codec.ParameterResolver = p => p == nm.Argument ? _stateVar : null; _codec = codec; var emitter = DnextFactory.NewILEmitter(ctx.Method.Module, ctx.Importer, _invCompiled); codec.EmitDemangler(emitter); }
public static void IColImplMain() { Test test = new Test(); IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); Driver <int, string> intStringDriver = new Driver <int, string>(test); Driver <string, int> stringIntDriver = new Driver <string, int>(test); test.Eval(intStringDriver.Verify(new GenerateItem <int>(intGenerator.NextValue), new GenerateItem <string>(stringGenerator.NextValue)), "Err_658865eido Test Int32, String FAILED\n"); test.Eval(stringIntDriver.Verify(new GenerateItem <string>(stringGenerator.NextValue), new GenerateItem <int>(intGenerator.NextValue)), "Err_40845ahekd Test String, Int32 FAILED\n"); Assert.True(test.Pass); }
/// <summary> /// Gets the list of neighborhood columns around the centar with the given radius in the specified topology. /// </summary> /// <param name="centerIndex"></param> /// <param name="radius"></param> /// <param name="topology"></param> /// <returns></returns> public static int[] GetNeighborhood(int centerIndex, int radius, HtmModuleTopology topology) { var centerPosition = HtmCompute.GetCoordinatesFromIndex(centerIndex, topology); IntGenerator[] intGens = new IntGenerator[topology.Dimensions.Length]; for (int i = 0; i < topology.Dimensions.Length; i++) { intGens[i] = new IntGenerator(Math.Max(0, centerPosition[i] - radius), Math.Min(topology.Dimensions[i] - 1, centerPosition[i] + radius) + 1); } List <List <int> > result = new List <List <int> >(); result.Add(new List <int>()); List <List <int> > interim = new List <List <int> >(); foreach (IntGenerator gen in intGens) { interim.Clear(); interim.AddRange(result); result.Clear(); foreach (var lx in interim) { gen.Reset(); for (int y = 0; y < gen.Size(); y++) { int py = gen.Next(); List <int> tl = new List <int>(); tl.AddRange(lx); tl.Add(py); result.Add(tl); } } } return(result.Select((tl) => GetFlatIndexFromCoordinates(tl.ToArray(), topology)).ToArray()); }
public static void SortedDictionary_ValueCollectionTest_Negative() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); //Scenario 1: Vanilla - fill in SortedDictionary with 10 keys and check this property Driver <int, int> IntDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); int count = 100; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; for (int i = 0; i < count; i++) { ints[i] = i; } IntDriver.TestVanilla_Negative(ints, ints); simpleRef.TestVanilla_Negative(simpleStrings, simpleStrings); simpleVal.TestVanilla_Negative(simpleInts, simpleInts); IntDriver.NonGenericIDictionaryTestVanilla_Negative(ints, ints); simpleRef.NonGenericIDictionaryTestVanilla_Negative(simpleStrings, simpleStrings); simpleVal.NonGenericIDictionaryTestVanilla_Negative(simpleInts, simpleInts); //Scenario 2: Check for an empty SortedDictionary IntDriver.TestVanilla_Negative(new int[0], new int[0]); simpleRef.TestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.TestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]); IntDriver.NonGenericIDictionaryTestVanilla_Negative(new int[0], new int[0]); simpleRef.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]); }
public static void RunTests() { Test test = new Test(); IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); //This mostly follows the format established by the original author of these tests //Scenario 1: Vanilla - fill in an SortedList with 10 keys and check this property Driver <int, int> IntDriver = new Driver <int, int>(test); Driver <SL.SimpleRef <String>, SL.SimpleRef <String> > simpleRef = new Driver <SL.SimpleRef <String>, SL.SimpleRef <String> >(test); Driver <SL.SimpleRef <int>, SL.SimpleRef <int> > simpleVal = new Driver <SL.SimpleRef <int>, SL.SimpleRef <int> >(test); SL.SimpleRef <int>[] simpleInts; SL.SimpleRef <String>[] simpleStrings; int[] ints; int count; count = 100; simpleInts = SL.SortedListUtils.GetSimpleInts(count); simpleStrings = SL.SortedListUtils.GetSimpleStrings(count); ints = new int[count]; for (int i = 0; i < count; i++) { ints[i] = i; } IntDriver.TestVanilla(ints, ints); simpleRef.TestVanilla(simpleStrings, simpleStrings); simpleVal.TestVanilla(simpleInts, simpleInts); IntDriver.NonGenericIDictionaryTestVanilla(ints, ints); simpleRef.NonGenericIDictionaryTestVanilla(simpleStrings, simpleStrings); simpleVal.NonGenericIDictionaryTestVanilla(simpleInts, simpleInts); IntDriver.TestVanillaIListReturned(ints, ints, -1); simpleRef.TestVanillaIListReturned(simpleStrings, simpleStrings, new SL.SimpleRef <string>("bozo")); simpleVal.TestVanillaIListReturned(simpleInts, simpleInts, new SL.SimpleRef <int>(-1)); IntDriver.TestVanillaICollectionReturned(ints, ints); simpleRef.TestVanillaICollectionReturned(simpleStrings, simpleStrings); simpleVal.TestVanillaICollectionReturned(simpleInts, simpleInts); //Scenario 2: Check for an empty SortedList IntDriver.TestVanilla(new int[0], new int[0]); simpleRef.TestVanilla(new SL.SimpleRef <String> [0], new SL.SimpleRef <String> [0]); simpleVal.TestVanilla(new SL.SimpleRef <int> [0], new SL.SimpleRef <int> [0]); IntDriver.NonGenericIDictionaryTestVanilla(new int[0], new int[0]); simpleRef.NonGenericIDictionaryTestVanilla(new SL.SimpleRef <String> [0], new SL.SimpleRef <String> [0]); simpleVal.NonGenericIDictionaryTestVanilla(new SL.SimpleRef <int> [0], new SL.SimpleRef <int> [0]); //Scenario 3: Check the underlying reference. Change the SortedList afterwards and examine ICollection keys and make sure that the //change is reflected SL.SimpleRef <int>[] simpleInts_1; SL.SimpleRef <String>[] simpleStrings_1; int[] ints_1; SL.SimpleRef <int>[] simpleInts_2; SL.SimpleRef <String>[] simpleStrings_2; int[] ints_2; int half = count / 2; simpleInts_1 = new SL.SimpleRef <int> [half]; simpleStrings_1 = new SL.SimpleRef <String> [half]; ints_2 = new int[half]; simpleInts_2 = new SL.SimpleRef <int> [half]; simpleStrings_2 = new SL.SimpleRef <String> [half]; ints_1 = new int[half]; for (int i = 0; i < half; i++) { simpleInts_1[i] = simpleInts[i]; simpleStrings_1[i] = simpleStrings[i]; ints_1[i] = ints[i]; simpleInts_2[i] = simpleInts[i + half]; simpleStrings_2[i] = simpleStrings[i + half]; ints_2[i] = ints[i + half]; } IntDriver.TestModify(ints_1, ints_1, ints_2); simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2); IntDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2); simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2); //Scenario 4: Change keys via ICollection (how?) and examine SortedList //How indeed? //Verify ICollection<V> through ICollection testing suite Driver <int, string> intStringDriver = new Driver <int, string>(test); Driver <string, int> stringIntDriver = new Driver <string, int>(test); test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue), new GenerateItem <string>(stringGenerator.NextValue), 0), "Err_085184aehdke Test Int32, String Empty Dictionary FAILED\n"); test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue), new GenerateItem <string>(stringGenerator.NextValue), 1), "Err_05164anhekjd Test Int32, String Dictionary with 1 item FAILED\n"); test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue), new GenerateItem <string>(stringGenerator.NextValue), 16), "Err_1088ajeid Test Int32, String Dictionary with 16 items FAILED\n"); test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue), new GenerateItem <int>(intGenerator.NextValue), 0), "Err_31288ajkekd Test String, Int32 Empty Dictionary FAILED\n"); test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue), new GenerateItem <int>(intGenerator.NextValue), 1), "Err_0215548aheuid Test String, Int32 Dictionary with 1 item FAILED\n"); test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue), new GenerateItem <int>(intGenerator.NextValue), 16), "Err_21057ajeipzd Test String, Int32 Dictionary with 16 items FAILED\n"); Assert.True(test.Pass); }
public void Zero() { var generator = new IntGenerator(0, 0); 10.Times(() => Assert.Equal(0, generator.GetRandomValue())); }
public static void SortedDictionary_KeyCollectionTest1() { IntGenerator intGenerator = new IntGenerator(); StringGenerator stringGenerator = new StringGenerator(); intGenerator.NextValue(); stringGenerator.NextValue(); //Scenario 1: Vanilla - fill in an SortedDictionary with 10 keys and check this property Driver <int, int> IntDriver = new Driver <int, int>(); Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(); Driver <SimpleRef <int>, SimpleRef <int> > simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(); int count = 1000; SimpleRef <int>[] simpleInts = SortedDictionaryUtils.GetSimpleInts(count); SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count); int[] ints = new int[count]; for (int i = 0; i < count; i++) { ints[i] = i; } IntDriver.TestVanilla(ints, ints); simpleRef.TestVanilla(simpleStrings, simpleStrings); simpleVal.TestVanilla(simpleInts, simpleInts); IntDriver.NonGenericIDictionaryTestVanilla(ints, ints); simpleRef.NonGenericIDictionaryTestVanilla(simpleStrings, simpleStrings); simpleVal.NonGenericIDictionaryTestVanilla(simpleInts, simpleInts); //Scenario 2: Check for an empty SortedDictionary IntDriver.TestVanilla(new int[0], new int[0]); simpleRef.TestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.TestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]); IntDriver.NonGenericIDictionaryTestVanilla(new int[0], new int[0]); simpleRef.NonGenericIDictionaryTestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]); simpleVal.NonGenericIDictionaryTestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]); //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the //change is reflected int half = count / 2; SimpleRef <int>[] simpleInts_1 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half]; SimpleRef <int>[] simpleInts_2 = new SimpleRef <int> [half]; SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half]; int[] ints_1 = new int[half]; int[] ints_2 = new int[half]; for (int i = 0; i < half; i++) { simpleInts_1[i] = simpleInts[i]; simpleStrings_1[i] = simpleStrings[i]; ints_1[i] = ints[i]; simpleInts_2[i] = simpleInts[i + half]; simpleStrings_2[i] = simpleStrings[i + half]; ints_2[i] = ints[i + half]; } IntDriver.TestModify(ints_1, ints_1, ints_2); simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2); IntDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2); simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2); simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2); }
public static bool GetRandomBool() { var randomInt = IntGenerator.GetRandomNumberInRange(0, 1); return(Convert.ToBoolean(randomInt)); }
public void Zero() { var generator = new IntGenerator(0, 0); 10.Times(() => Assert.Equal(0, generator.GetRandomValue())); }
public TitleGenerator(int min, int max) { lengthGenerator = new IntGenerator(min, max); }
public GeneratorOptions <T> Range(Expression <Func <T, int> > propertyExpression, int min, int max) { var generator = new IntGenerator(min, max); return(For(propertyExpression, generator)); }
public void SetOfOneThreeElements() { var generator = new IntGenerator(42, 45).Unique(); 3.Times(() => generator.GetRandomValue()); Assert.Throws<HeyITriedFiftyTimesButCouldNotGetADifferentValue>(() => generator.GetRandomValue()); }
public void DefaultGeneratorNeverGeneratesZero() { var generator = new IntGenerator(); 100.Times(() => Assert.NotEqual(0, generator.GetRandomValue())); }
public static TimeSpan GetRandomTimeSpan() { return(TimeSpan.FromMilliseconds(IntGenerator.GetRandomNumberInRange(1, 200000000))); }
public override void Arrange() { client = MockRepository.GenerateMock<IClientProxy>(); sleepTime = new IntGenerator(0, 10).GetRandomValue(); }
public IEnumerable <T> Many <T>(int minNumberOfMany, int maxNumberOfMany) { var numberOfMany = new IntGenerator(minNumberOfMany, maxNumberOfMany).GetRandomValue(); return(PrivateMany <T>(numberOfMany).ToList()); }
public static decimal GetRandomDecimal() { var randomInt = IntGenerator.GetRandomNumberInRange(100, 10000000); return(randomInt / 10.0m); }
public void DefaultGeneratorNeverGeneratesZero() { var generator = new IntGenerator(); 100.Times(() => Assert.NotEqual(0, generator.GetRandomValue())); }
public override void Arrange() { a = new IntGenerator(0, 20).GetRandomValue(); b = new IntGenerator(0, 20).GetRandomValue(); }