public void DateTimesStayWithinConfiguredDates() { var success = true; // use a small window to try to force collisions var minDate = DateTime.Now.AddMilliseconds(-5); var maxDate = DateTime.Now.AddMilliseconds(5); for (int i = 0; i < 500; i++) { Angie.Default() .DateRange(DateTime.Now.AddMilliseconds(-10), DateTime.Now.AddMilliseconds(10)); var person = Angie .Configure() .Make <Person>(); if (!(person.BirthDate >= minDate && person.BirthDate <= maxDate)) { success = false; } else { Assert.IsTrue(success, "Date was generated outside of range.{0}", person.BirthDate); } } }
public void MakeListGeneratesCorrectNumberOfEntriesWithDefaults() { Angie.Reset(); var personCount = 13; Angie.Default() .ListCount(personCount); var people = Angie .FastList <Person>(); Assert.AreEqual(people.Count(), personCount); }
private static void PleaseAddressMe() { Angie.Default() .ListCount(3); var addresses = Angie .Configure() .MakeList <Location>(); foreach (var location in addresses) { Console.WriteLine(location); } }
private static void WriteSomePeepsOut() { Angie.Default() .ListCount(3); var people = Angie .Configure() .MakeList <Person>(); foreach (var person in people) { Console.WriteLine(person); } }
public void FillPropertyWithRandomValuesFromList() { IList <Person> peeps = Angie.FastList <Person>(10); Angie.Default().ListCount(25); IList <Dog> dogs = Angie.Configure <Dog>().Fill(d => d.Owner).WithRandom(peeps).MakeList(); foreach (Dog dog in dogs) { Assert.IsNotNull(dog.Owner); CollectionAssert.Contains(peeps, dog.Owner); } }
public void ComplexPropertyFillsExecuted() { Angie.Default() .ListCount(5); var postcomments = Angie .Configure() .MakeList <BlogComment>(); var blogpost = Angie .Configure <BlogPost>() .Fill(b => b.Comments, delegate { return(postcomments); }) .Make <BlogPost>(); Assert.IsNotNull(blogpost.Comments); }
public void DateTimeFilledWithExpectedDateGivenRules() { var future = DateTime.Now.AddSeconds(1); Angie.Default() .ListCount(1000); var comments = Angie .Configure <BlogComment>() .Fill(b => b.CommentDate, delegate() { return(CalendarDate.Date(DateRules.FutureDates)); }) .MakeList <BlogComment>(); foreach (var comment in comments) { Assert.Greater(comment.CommentDate, future); } }
public void IntMaxNotExceededOnGeneratedValue() { var maxNumberOfKids = 5; Angie.Default() .MaxInt(maxNumberOfKids); for (int i = 0; i < 500; i++) { var person = Angie .FastMake <Person>(); if (!(person.NumberOfKids <= maxNumberOfKids)) { Assert.Fail("Int max was exceeded: {0} ", person.NumberOfKids); } } }
public void ShortMinNotExceededOnGeneratedValue() { short minNumberOfKids = 5; Angie.Default() .MinShort(minNumberOfKids); for (int i = 0; i < 500; i++) { var instance = Angie .FastMake <ClassWithShortProperty>(); if (!(instance.ShortProperty >= minNumberOfKids)) { Assert.Fail("Short min was exceeded: {0} ", instance.ShortProperty); } } }
public void ShortMaxNotExceededOnGeneratedValue() { short maxShort = 4; Angie.Default() .MaxShort(maxShort); for (int i = 0; i < 500; i++) { var instance = Angie .FastMake <ClassWithShortProperty>(); if (!(instance.ShortProperty <= maxShort)) { Assert.Fail("Short max was exceeded: {0} ", instance.ShortProperty); } } }
public void CustomPropertyFillsAreChainableUsingSet() { Angie.Default() .ListCount(5); var blogpost = Angie .Configure <BlogPost>() .Fill(b => b.CreateDate, delegate() { return(CalendarDate.Date(DateRules.PastDate)); }) .Fill(b => b.Comments, delegate() { return(Angie .Set <BlogComment>() .Fill(b => b.CommentDate, delegate() { return CalendarDate.Date(DateRules.PastDate); }) .MakeList <BlogComment>()); }) .Make <BlogPost>(); Assert.IsNotNull(blogpost.Comments); }
private static void PostMeSomeBlogs() { Angie.Default() .ListCount(3); var blogposts = Angie .Configure <BlogPost>() .Fill(d => d.CreateDate).AsPastDate() .Fill(b => b.Comments, () => { return(Angie .Set <BlogComment>() .Fill(d => d.CommentDate).AsPastDate() .MakeList <BlogComment>()); }) .MakeList <BlogPost>(); foreach (var post in blogposts) { Console.WriteLine(post.Title); } }