Exemple #1
0
        public void UserListIsPopulated()
        {
            var users = new List <User>();

            Angie.Configure <User>().MakeList().ForEach(x => users.Add(x));
            Assert.IsTrue(users.Count > 0);
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        public void MakeListDefaultsTo25Entries()
        {
            var people = Angie
                         .Configure()       // get an instantiated object for the non-static call
                         .MakeList <Person>();

            Assert.IsTrue(people.Count() == Angie.Defaults.LIST_COUNT);
        }
Exemple #4
0
        public void MethodCanBeSet()
        {
            var expected = "q";
            var person   = Angie.Configure <Person>().MethodFill <string>(x => x.SetMiddleName(null), () => expected).Make <Person>();

            Assert.IsTrue(!string.IsNullOrEmpty(person.GetMiddleName()));
            Assert.AreEqual(expected, person.GetMiddleName());
        }
Exemple #5
0
        public void UserNameIsPopulated()
        {
            var users = new List <User>();

            Angie.Configure <User>().Fill(x => x.Name, () => Names.FullName()).MakeList().ForEach(x => users.Add(x));
            foreach (var user in users)
            {
                Assert.IsTrue(user.Name.Split(' ').Count() > 1);
            }
        }
Exemple #6
0
        public void IntPropertyFilledBySpecificMethod()
        {
            var age = 11;

            var person = Angie.Configure <Person>()
                         .Fill(p => p.Age, delegate() { return(age); })
                         .Make <Person>();

            Assert.IsTrue(person.Age == age);
        }
Exemple #7
0
        public void StringPropertyFilledBySpecificMethod()
        {
            var blogTitle = "Angie";

            var post = Angie.Configure <BlogPost>()
                       .Fill(b => b.Title, () => blogTitle)
                       .Make <BlogPost>();

            Assert.AreEqual(blogTitle, post.Title);
        }
Exemple #8
0
        private static void AFlight()
        {
            var flights = Angie
                          .Configure <Flight>()
                          .Fill(x => x.Range).WithinRange(1000, 10000)
                          .Fill(x => x.FlightNumber).WithRandom(new [] { "AC", "WJ", "SW" })
                          .Fill(x => x.PlaneType, GetRandomPlaneName)
                          .MakeList <Flight>();

            flights.ForEach(x => Console.WriteLine(x));
        }
Exemple #9
0
        public void MakeListGeneratesCorrectNumberOfEntriesWithInstanceOverload()
        {
            Angie.Reset();
            var personCount = 13;

            var people = Angie
                         .Configure <Person>()
                         .MakeList <Person>(personCount);

            Assert.AreEqual(people.Count(), personCount);
        }
Exemple #10
0
        public void AsEmailAddressForDomain()
        {
            var domain = "foofoofoobarbarbar.com";

            var person = Angie.Configure <Person>()
                         .Fill(p => p.EmailAddress)
                         .AsEmailAddressForDomain(domain)
                         .Make <Person>();

            Assert.True(person.EmailAddress.Contains(domain));
        }
Exemple #11
0
        public void MethodFillStrategyCanBeSpecified()
        {
            IList <string> names = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var person =
                Angie.Configure <Person>()
                .MethodFill <string>(x => x.SetMiddleName(null))
                .WithRandom(names)
                .Make <Person>();

            Assert.IsTrue(!string.IsNullOrEmpty(person.GetMiddleName()));
            CollectionAssert.Contains(names, person.GetMiddleName());
        }
        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);
            }
        }
Exemple #13
0
        private static void WriteSomePeepsOut()
        {
            Angie.Default()
            .ListCount(3);

            var people = Angie
                         .Configure()
                         .MakeList <Person>();

            foreach (var person in people)
            {
                Console.WriteLine(person);
            }
        }
Exemple #14
0
        private static void PleaseAddressMe()
        {
            Angie.Default()
            .ListCount(3);

            var addresses = Angie
                            .Configure()
                            .MakeList <Location>();

            foreach (var location in addresses)
            {
                Console.WriteLine(location);
            }
        }
Exemple #15
0
        private static void ANewTrendInMusic()
        {
            var artists = Angie.FastList <Artist>(50);

            var genres = Angie.FastList <Genre>(20);

            var album = Angie
                        .Configure <Album>()
                        .Fill(a => a.Price).WithinRange(7, 10)
                        .Fill(a => a.Artist).WithRandom(artists)
                        .Fill(a => a.Genre).WithRandom(genres)
                        .Make <Album>();

            Console.WriteLine(album.ToString());
        }
Exemple #16
0
        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);
        }
 static PersonController()
 {
     _people = Angie.Configure <Person>()
               .Fill(p => p.BirthDate)
               .AsPastDate()
               .Fill(p => p.LikesMusic)
               .WithRandom(new List <bool>()
     {
         true, true, true, false, false
     })
               .Fill(p => p.Skills, () => new List <string>()
     {
         "Math", "Science", "History"
     })
               .MakeList <Person>(20);
 }
Exemple #18
0
        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);
            }
        }
Exemple #19
0
        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);
        }
Exemple #20
0
        public void CustomPropertyFillsAreChainableUsingConfigure()
        {
            const string theTitle = "THE TITLE";

            var blogposts = Angie
                            .Configure <BlogPost>()
                            .Fill(b => b.Title, () => theTitle)
                            .Fill(b => b.Comments, delegate()
            {
                return(Angie
                       .Configure <BlogComment>()
                       .Fill(b => b.CommentDate, delegate() { return CalendarDate.Date(DateRules.PastDate); })
                       .MakeList <BlogComment>());
            })
                            .MakeList <BlogPost>();

            foreach (var blogPost in blogposts)
            {
                Assert.AreEqual(theTitle, blogPost.Title);
            }
        }
Exemple #21
0
 static MainController()
 {
     _people = Angie.Configure <Person>()
               .Fill(p => p.BirthDate)
               .AsPastDate()
               .Fill(p => p.LikesMusic)
               .WithRandom(new List <bool>()
     {
         true, true, true, false, false
     })
               .Fill(p => p.FavoriteMusic)
               .WithRandom(new List <MusicGenre>()
     {
         MusicGenre.Country, MusicGenre.Gospel, MusicGenre.HipHop, MusicGenre.Pop, MusicGenre.RB, MusicGenre.Rock
     })
               .Fill(p => p.Skills, () => new List <string>()
     {
         "Math", "Science", "History", "POKEMON GO"
     })
               .MakeList <Person>(20);
 }
Exemple #22
0
        public void ShortRangeWithinBoundsOnGeneratedValue()
        {
            // use a small window to try to force collisions
            const short minValue = 20;
            const short maxValue = 22;

            Angie.Reset();

            for (int i = 0; i < 500; i++)
            {
                var person = Angie
                             .Configure <ClassWithShortProperty>()
                             .Fill(p => p.ShortProperty)
                             .WithinRange(minValue, maxValue)
                             .Make();

                bool success = (person.ShortProperty >= minValue && person.ShortProperty <= maxValue);

                Assert.IsTrue(success, "Short was generated outside of range.{0}", person.ShortProperty);
            }
        }
Exemple #23
0
        static void Main(string[] args)
        {
            var students =
                Angie.Configure <Student>()
                .Fill(p => p.FirstName).AsFirstName()
                .Fill(p => p.LastName).AsLastName()
                .Fill(p => p.Grade).WithinRange(2, 7)
                .MakeList <Student>(10);
            var workers =
                Angie.Configure <Worker>()
                .Fill(p => p.FirstName).AsFirstName()
                .Fill(p => p.LastName).AsLastName()
                .Fill(p => p.WeekSalary).WithinRange(300, 1001)
                .Fill(p => p.WorkHoursPerDay).WithinRange(2, 10)
                .MakeList <Worker>(10);

            foreach (var worker in workers)
            {
                worker.CalculateMoneyPerHour();
            }

            var studentsAscending =
                from student in students
                orderby student.Grade ascending
                select student;
            var workersDescending =
                from worker in workers
                orderby worker.MoneyPerHour descending
                select worker;

            foreach (var student in studentsAscending)
            {
                Console.WriteLine(student);
            }

            foreach (var worker in workersDescending)
            {
                Console.WriteLine(worker);
            }
        }
Exemple #24
0
        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);
            }
        }
Exemple #25
0
        public void IntRangeWithinBoundsOnGeneratedValue()
        {
            var success = true;

            // use a small window to try to force collisions
            var minAge = 20;
            var maxAge = 22;

            Angie.Reset();

            for (int i = 0; i < 500; i++)
            {
                var person = Angie
                             .Configure <Person>()
                             .Fill(p => p.Age)
                             .WithinRange(minAge, maxAge)
                             .Make <Person>();

                success = (person.Age >= minAge && person.Age <= maxAge);

                Assert.IsTrue(success, "Int was generated outside of range.{0}", person.Age);
            }
        }
Exemple #26
0
        public void IdIsPopulated()
        {
            var user = Angie.Configure <User>().Make();

            Assert.IsNotNull(user.Id);
        }
Exemple #27
0
        public void IngredientsIsPopulated()
        {
            var recipe = Angie.Configure <Recipe>().Make();

            Assert.IsNotNull(recipe.Ingredients);
        }
Exemple #28
0
 public void ShouldIgnoreUnsettableProperties()
 {
     var list = Angie.Configure <BlogCommenter>()
                .MakeList <BlogCommenter>();
 }
Exemple #29
0
        public void MethodIsFilledWhenSpecified()
        {
            var person = Angie.Configure <Person>().MethodFill <string>(x => x.SetMiddleName(null)).Make <Person>();

            Assert.IsTrue(!string.IsNullOrEmpty(person.GetMiddleName()));
        }