예제 #1
0
        public static T FillObject <T>() where T : class
        {
            var randomStringGenerator = new MnemonicString(2);

            var filler = new Filler <T>();

            filler.Setup().OnType <ByteString>().Use(ByteString.CopyFrom(randomStringGenerator.GetValue(), Encoding.Unicode));
            filler.Setup().OnType <Timestamp>().Use(Timestamp.FromDateTime(DateTime.UtcNow)); //should be UTC
            filler.Setup().OnType <Duration>().Use(Duration.FromTimeSpan(new TimeSpan(100)));
            return(filler.Create());
        }
예제 #2
0
        public void Must_support_class_with_enums_as_ctor_out_of_the_box()
        {
            var filler = new Filler <MyClassWithCstr>();

            filler.Setup().OnProperty(x => x.Manual).Use(() => ManualSetupEnum.B);

            for (int n = 0; n < 1000; n++)
            {
                var c = filler.Create();

                Assert.IsTrue(
                    c.Standard == StandardEnum.A ||
                    c.Standard == StandardEnum.B ||
                    c.Standard == StandardEnum.C);

                Assert.IsTrue(
                    c.Numbered == NumberedEnum.A ||
                    c.Numbered == NumberedEnum.B ||
                    c.Numbered == NumberedEnum.C);

                Assert.IsTrue(
                    c.Flags == FlagsEnum.A ||
                    c.Flags == FlagsEnum.B ||
                    c.Flags == FlagsEnum.C);

                Assert.IsTrue((int)c.Nasty == 0);

                Assert.IsTrue(c.Manual == ManualSetupEnum.B);
            }
        }
        public static List <CustomerDto> GetData(int customersCount)
        {
            Filler <CustomerDto> filler = new Filler <CustomerDto>();

            filler.Setup();
            return(filler.Create(customersCount).ToList());
        }
        public static List <CityDto> GetAddresses(int citiesCount)
        {
            Filler <CityDto> filler = new Filler <CityDto>();

            filler.Setup();
            return(filler.Create(citiesCount).ToList());
        }
        public void RecursiveFill_RecursiveType_ThrowsException()
        {
            var filler = new Filler <TestParent>();

            filler.Setup().OnCircularReference().ThrowException();
            Assert.ThrowsException <InvalidOperationException>(() => filler.Create());
        }
예제 #6
0
		public void Must_support_enums_out_of_the_box()
		{
			var filler = new Filler<MyClass>();
			filler.Setup()
				.OnProperty(x => x.Manual).Use(() => ManualSetupEnum.B)
				.OnProperty(x => x.Ignored).IgnoreIt();

			for (int n = 0; n < 1000; n++)
			{
				var c = filler.Create();

				Assert.IsTrue(
					c.Standard == StandardEnum.A || 
					c.Standard == StandardEnum.B || 
					c.Standard == StandardEnum.C);

				Assert.IsTrue(
					c.Numbered == NumberedEnum.A ||
					c.Numbered == NumberedEnum.B ||
					c.Numbered == NumberedEnum.C);

				Assert.IsTrue(
					c.Flags == FlagsEnum.A ||
					c.Flags == FlagsEnum.B ||
					c.Flags == FlagsEnum.C);

				Assert.IsTrue((int)c.Nasty == 0);

				Assert.IsTrue(c.Manual == ManualSetupEnum.B);

				Assert.IsTrue((int)c.Ignored == 0);
			}
		}
예제 #7
0
        public void RecursiveFill_RecursiveType_ThrowsException()
        {
            var filler = new Filler <TestParent>();

            filler.Setup().OnCircularReference().ThrowException();
            filler.Create();
        }
예제 #8
0
        public void RecursiveFill_SelfReferencing_Fails()
        {
            var filler = new Filler <TestSelf>();

            filler.Setup().OnCircularReference().ThrowException();
            filler.Create();
        }
예제 #9
0
        public void RecursiveFill_RecursiveType_Child_First_Fails()
        {
            var filler = new Filler <TestChild>();

            filler.Setup().OnCircularReference().ThrowException();
            filler.Create();
        }
예제 #10
0
        public void RecursiveFill_DeepRecursiveType_Fails()
        {
            var filler = new Filler <TestGrandParent>();

            filler.Setup().OnCircularReference().ThrowException();
            filler.Create();
        }
예제 #11
0
        public void RecursiveFill_RecursiveType_Child_First_Fails()
        {
            var filler = new Filler <TestChild>();

            filler.Setup().OnCircularReference().ThrowException();
            Assert.Throws <InvalidOperationException>(() => filler.Create());
        }
        public RunnerRepository(CategoryRepository categoryRepository)
        {
            var runnerFiller = new Filler <Runner>();

            runnerFiller.Setup()
            .OnProperty(r => r.Id).IgnoreIt()
            .OnProperty(r => r.Category).IgnoreIt()
            .OnProperty(r => r.CategoryId).IgnoreIt()
            .OnProperty(r => r.ChipId).IgnoreIt()
            .OnProperty(r => r.RunningTime).IgnoreIt()
            .OnProperty(r => r.TimeAtDestination).IgnoreIt()
            .OnProperty(r => r.Startnumber).Use(new IntRange(1, 500))
            .OnProperty(r => r.YearOfBirth).Use(new IntRange(DateTime.Now.Year - 70, DateTime.Now.Year - 3))
            .OnProperty(r => r.Firstname).Use(new RealNames(NameStyle.FirstName))
            .OnProperty(r => r.Lastname).Use(new RealNames(NameStyle.LastName))
            .OnProperty(r => r.Email).Use(new EmailAddresses())
            .OnProperty(r => r.SportsClub).Use(new RandomListItem <string>(
                                                   "SC Mining", null, "SV Ried", "SV Altheim"));

            var runners    = runnerFiller.Create(30);
            var random     = new Random();
            var categories = categoryRepository.GetAll().ToList();

            foreach (var r in runners)
            {
                r.Category   = categories[random.Next(0, categories.Count)];
                r.CategoryId = r.Category.Id;
            }
            _runners = runners.ToImmutableList();
        }
예제 #13
0
        private async ValueTask <StudentExam> CreateRandomStudentExamAsync()
        {
            DateTimeOffset now           = DateTimeOffset.UtcNow;
            Teacher        randomTeacher = await PostRandomTeacherAsync();

            Student randomStudent = await PostRandomStudentAsync();

            Course randomCourse = await PostRandomCourseAsync();

            Classroom randomClassroom = await PostRandomClassroomAsync();

            Exam randomExam = await PostRandomExamAsync(randomTeacher, randomCourse, randomClassroom);

            Guid userId = Guid.NewGuid();
            var  filler = new Filler <StudentExam>();

            filler.Setup()
            .OnProperty(studentExam => studentExam.CreatedBy).Use(userId)
            .OnProperty(studentExam => studentExam.UpdatedBy).Use(userId)
            .OnProperty(studentExam => studentExam.CreatedDate).Use(now)
            .OnProperty(studentExam => studentExam.UpdatedDate).Use(now)
            .OnProperty(studentExam => studentExam.StudentId).Use(randomStudent.Id)
            .OnProperty(studentExam => studentExam.ExamId).Use(randomExam.Id)
            .OnProperty(studentExam => studentExam.TeacherId).Use(randomTeacher.Id)
            .OnType <DateTimeOffset>().Use(GetRandomDateTime());

            return(filler.Create());
        }
예제 #14
0
        public async Task AddAuthorAsync_ShouldReturnExpectedAuthorWithId()
        {
            // given (arrange)
            Filler <CreateAuthorDto> authorFiller = new Filler <CreateAuthorDto>();

            authorFiller.Setup()
            .OnProperty(x => x.ContactEmail)
            .Use(new EmailAddresses(".com"))
            .OnProperty(x => x.ContactPhoneNumber)
            .Use("555-555-5555");

            CreateAuthorDto authorDtoToAdd = authorFiller.Create();

            Author authorToAdd = this.mapper.Map <Author>(authorDtoToAdd);

            Author databaseAuthor = this.mapper.Map <Author>(authorToAdd);

            databaseAuthor.Id          = 1;
            databaseAuthor.DateCreated = databaseAuthor.DateUpdated = DateTime.UtcNow;

            this.appDbContextMock
            .Setup(db => db.CreateAuthorAsync(It.IsAny <Author>()))
            .ReturnsAsync(databaseAuthor);

            // when (act)
            var actualAuthor = await subject.AddAuthorAsync(authorDtoToAdd);

            // then (assert)
            actualAuthor.Should().BeEquivalentTo(databaseAuthor);
            appDbContextMock.Verify(db => db.CreateAuthorAsync(It.IsAny <Author>()), Times.Once);
            appDbContextMock.VerifyNoOtherCalls();
        }
        public void RecursiveFill_SelfReferencing_Fails()
        {
            var filler = new Filler <TestSelf>();

            filler.Setup().OnCircularReference().ThrowException();
            Assert.ThrowsException <InvalidOperationException>(() => filler.Create());
        }
        private static Filler <Student> CreateStudentFiller()
        {
            var filler = new Filler <Student>();

            filler.Setup().OnType <DateTimeOffset>().Use(DateTimeOffset.UtcNow);

            return(filler);
        }
        public void RecursiveFill_WithFunc_Succeeds()
        {
            var filler = new Filler<TestParent>();
            filler.Setup().OnProperty(p => p.Child).Use(() => new TestChild());
            var result = filler.Create();

            Assert.NotNull(result.Child);
        }
        public void RecursiveFill_WithIgnoredProperties_Succeeds()
        {
            var filler = new Filler<TestParent>();
            filler.Setup().OnProperty(p => p.Child).IgnoreIt();
            var result = filler.Create();

            Assert.NotNull(result);
        }
예제 #19
0
        private Filler <Geo> CreateGeoFiller()
        {
            var filler = new Filler <Geo>();

            filler.Setup()
            .OnProperty(geo => geo.City).Use(new CityName());

            return(filler);
        }
예제 #20
0
        private static Filler <Teacher> CreateRandomTeacherFiller(DateTimeOffset dates)
        {
            var filler = new Filler <Teacher>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dates);

            return(filler);
        }
        private static Filler <StudentContact> CreateStudentContactFiller(DateTimeOffset dates)
        {
            var filler = new Filler <StudentContact>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dates);

            return(filler);
        }
예제 #22
0
 public static Filler <Course> SetupRandomCourseGenerator(this Filler <Course> randomCourseGenerator)
 {
     randomCourseGenerator.Setup().
     OnProperty(x => x.Id).IgnoreIt().
     // Remember to ignore related tables.
     OnProperty(x => x.Students).IgnoreIt().
     OnProperty(x => x.Name).Use(new MnemonicString(wordCount: 2));
     return(randomCourseGenerator);
 }
예제 #23
0
        private Filler <Guardian> CreateRandomGuardianFiller(DateTimeOffset dateTime)
        {
            var filler = new Filler <Guardian>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dateTime);

            return(filler);
        }
예제 #24
0
        private static Filler <Movie> CreateMovieFiller()
        {
            var filler = new Filler <Movie>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(DateTimeOffset.UtcNow);

            return(filler);
        }
예제 #25
0
        private static Filler <Classroom> CreateClassroomFiller(DateTimeOffset dates)
        {
            var filler = new Filler <Classroom>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dates);

            return(filler);
        }
        public void IfIgnoreInheritanceIsSetToTrueTheNameOfTheStudentShouldBeNull()
        {
            Filler<Student> filler = new Filler<Student>();
            filler.Setup().IgnoreInheritance();
            var student = filler.Create();

            Assert.Null(student.FirstName);
            Assert.NotNull(student.Class);
        }
        public void RecursiveFill_WithFunc_Succeeds()
        {
            var filler = new Filler <TestParent>();

            filler.Setup().OnProperty(p => p.Child).Use(() => new TestChild());
            var result = filler.Create();

            Assert.IsNotNull(result.Child);
        }
        public void RecursiveFill_WithIgnoredProperties_Succeeds()
        {
            var filler = new Filler <TestParent>();

            filler.Setup().OnProperty(p => p.Child).IgnoreIt();
            var result = filler.Create();

            Assert.IsNotNull(result);
        }
예제 #29
0
        private Filler <Course> CreateRandomCourseFiller(DateTimeOffset dateTime)
        {
            var filler = new Filler <Course>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dateTime);

            return(filler);
        }
예제 #30
0
        private static Filler <Attendance> GetAttendanceFiller(DateTimeOffset dateTime)
        {
            Filler <Attendance> attendance = new Filler <Attendance>();

            attendance.Setup()
            .OnType <DateTimeOffset>().Use(dateTime);

            return(attendance);
        }
예제 #31
0
        private static Filler <BookView> CreateBookFiller()
        {
            var filler = new Filler <BookView>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(DateTimeOffset.UtcNow);

            return(filler);
        }
예제 #32
0
        private static Filler <Contact> CreateRandomContactFiller(DateTimeOffset dateTime)
        {
            Filler <Contact> filler = new Filler <Contact>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dateTime);

            return(filler);
        }
예제 #33
0
        private static Filler <Course> CreateCourseFiller()
        {
            var filler = new Filler <Course>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(valueToUse: GetRandomDateTime());

            return(filler);
        }
예제 #34
0
        private static Filler <Tag> CreateRandomTagFiller(DateTimeOffset dateTime)
        {
            Filler <Tag> filler = new Filler <Tag>();

            filler.Setup()
            .OnType <DateTimeOffset>().Use(dateTime);

            return(filler);
        }
        public void Test_With_France_High_Values_Settings()
        {
            Filler<Book> book = new Filler<Book>();
            book.Setup()
                .OnProperty(x => x.ISBN).Use(new Lipsum(LipsumFlavor.LeMasque, 20, 50, 100, 250, 500));

            var b = book.Create();

            Assert.IsNotNull(b);
        }
        public void Test_With_German_Default_Settings()
        {
            Filler<Book> book = new Filler<Book>();
            book.Setup()
                .OnProperty(x => x.ISBN).Use(new Lipsum(LipsumFlavor.InDerFremde));

            var b = book.Create();

            Assert.IsNotNull(b);
        }
        public void Test_With_Many_MinWords_And_Many_MinSentences()
        {
            Filler<Book> book = new Filler<Book>();
            book.Setup()
                .OnProperty(x => x.ISBN).Use(new Lipsum(LipsumFlavor.InDerFremde, 3, 9, minWords: 51));

            var b = book.Create();

            Assert.IsNotNull(b);
        }
        public void UseSavedFillerDefaultSetup()
        {
            Filler<Person> filler = new Filler<Person>();
            filler.Setup(_fillerSetup);

            Person p = filler.Create();

            Assert.IsTrue(p.Age < 35 && p.Age >= 18);
            Assert.IsTrue(p.Address.HouseNumber < 100 && p.Age >= 1);
        }
        public void TestFillLibraryWithDictionary()
        {
            Filler<LibraryConstructorDictionary> lib = new Filler<LibraryConstructorDictionary>();
            lib.Setup()
                .OnType<IBook>().CreateInstanceOf<Book>()
                .OnProperty(x => x.Books).IgnoreIt();

            LibraryConstructorDictionary filledLib = lib.Create();
            Assert.NotNull(filledLib.Books);
        }
예제 #40
0
        public void TestFillLibraryWithPocoOfABook()
        {
            Filler<LibraryConstructorPoco> lib = new Filler<LibraryConstructorPoco>();
            lib.Setup()
                .OnProperty(x => x.Books).IgnoreIt();

            LibraryConstructorPoco filledLib = lib.Create();
            Assert.IsNotNull(filledLib.Books);
            Assert.AreEqual(1, filledLib.Books.Count);
        }
예제 #41
0
        public void RandomizerCreatesObjectsBasedOnPreviouseSetups()
        {
            int givenValue = Randomizer<int>.Create();

            var childFiller = new Filler<Child>();
            var childSetup = childFiller.Setup().OnProperty(x => x.IntValue).Use(givenValue).Result;
            
            var child = Randomizer<Child>.Create(childSetup);
            Assert.Equal(givenValue, child.IntValue);
        }
        public void IfIgnoreInheritanceIsSetToFalseTheNameOfTheStudentShouldNotBeNull()
        {
            Filler<Student> filler = new Filler<Student>();
            filler.Setup()
                .OnType<IAddress>().CreateInstanceOf<Address>();
            var student = filler.Create();

            Assert.NotNull(student.FirstName);
            Assert.NotNull(student.Class);
        }
예제 #43
0
        public void WhenConstructorWithDateTimeNowWillBeCalledNoExceptionShouldBeThrown()
        {
            Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();

            filler.Setup().OnProperty(x => x.Date).Use(new DateTimeRange(DateTime.Now));

            var dateTime = filler.Create();

            Assert.True(dateTime.Date > DateTime.MinValue);
            Assert.True(dateTime.Date < DateTime.MaxValue);
        }
예제 #44
0
        public void WhenStartDateIsBiggerThenEndDateTheDatesShouldBeSwitched()
        {
            Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();

            filler.Setup().OnType<DateTime>().Use(
                new DateTimeRange(DateTime.Now, DateTime.Now.AddDays(-31)));

            var d = filler.Create(1000);

            Assert.True(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
        }
예제 #45
0
        public void WhenGettingDatesBetweenNowAnd31DaysAgo()
        {
            Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();

            filler.Setup().OnType<DateTime>().Use(
                new DateTimeRange(DateTime.Now.AddDays(-31)));

            var d = filler.Create(1000);

            Assert.True(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
        }
예제 #46
0
        public void TestFillLibraryWithListOfIBooks()
        {
            Filler<LibraryConstructorList> lib = new Filler<LibraryConstructorList>();
            lib.Setup()
                .OnProperty(x => x.Books).IgnoreIt()
                .OnType<IBook>().CreateInstanceOf<Book>();

            LibraryConstructorList filledLib = lib.Create();

            Assert.IsNotNull(filledLib.Books);
        }
예제 #47
0
        public void TestRealNameFirstNameOnly()
        {
            Filler<LibraryFillingTest.Person> filler = new Filler<LibraryFillingTest.Person>();
            filler.Setup()
                .OnProperty(x => x.Name).Use(new RealNames(RealNameStyle.FirstNameOnly));

            LibraryFillingTest.Person p = filler.Create();

            Assert.IsNotNull(p);
            Assert.IsNotNull(p.Name);
            Assert.IsFalse(p.Name.Contains(" "));
        }
예제 #48
0
        public void TestCityNames()
        {
            var filler = new Filler<CollectionizerPoco>();

            filler.Setup()
                .OnProperty(x => x.ArrayList)
                .Use(new Collectionizer<string, MnemonicString>(new MnemonicString(1, 20, 25), 3, 10));

            var arrayList = filler.Create();
            Assert.True(arrayList.ArrayList.Count >= 3 && arrayList.ArrayList.Count <= 10);
            Assert.True(arrayList.ArrayList.ToArray().Cast<string>().All(x => x.Length >= 20 && x.Length <= 25));
        }
        public void Test_With_English_Min_Values_Settings()
        {
            Filler<Book> book = new Filler<Book>();
            book.Setup()
                .OnProperty(x => x.ISBN).Use(new Lipsum(LipsumFlavor.ChildHarold, 1, 1, 1, 1, 1));

            var b = book.Create();

            b.ISBN = b.ISBN.Replace("\r\n\r\n", string.Empty);
            Assert.IsNotNull(b);
            Assert.AreEqual(1, b.ISBN.Split('\n').Length);
        }
        public PersonSelectionDesignViewModel()
        {
            var filler = new Filler<Person>();

            filler.Setup()
                    .OnProperty(x => x.FirstName)
                    .Use(new RealNames(NameStyle.FirstName))
                    .OnProperty(x => x.LastName)
                    .Use(new RealNames(NameStyle.LastName));

            this.AvailablePersons = filler.Create(5);
        }
 public void TestIgnoreAllUnknownTypesWithOutException()
 {
     Filler<EntityCollection> filler = new Filler<EntityCollection>();
     filler.Setup().IgnoreAllUnknownTypes();
     var entity = filler.Create();
     Assert.IsNull(entity.EntityArray);
     Assert.IsNotNull(entity);
     Assert.IsNotNull(entity.EntityList);
     Assert.IsNotNull(entity.EntityICollection);
     Assert.IsNotNull(entity.EntityIEnumerable);
     Assert.IsNotNull(entity.EntityIList);
 }
예제 #52
0
        public void TestMnemonicStringPlugin()
        {
            var filler = new Filler<CollectionizerPoco>();

            filler.Setup()
                .OnProperty(x => x.MnemonicStrings)
                .Use(new Collectionizer<string, MnemonicString>(new MnemonicString(1, 20, 25), 3, 10));

            var collection = filler.Create();
            Assert.True(collection.MnemonicStrings.Count() >= 3 && collection.MnemonicStrings.Count() <= 10);
            Assert.True(collection.MnemonicStrings.All(x => x.Length >= 20 && x.Length <= 25));
        }
예제 #53
0
        public void ExplicitSetupShallJustFillPropertiesWhichAreSetUpAndNoInstanceShallCreateForSubTypesIfNotSetup()
        {
            Filler<Parent> filler = new Filler<Parent>();
            filler.Setup(true)
               .OnProperty(x => x.SomeId).Use(new IntRange(1, 20));

            var parent = filler.Create();

            Assert.NotNull(parent);
            Assert.Null(parent.Child);
            Assert.NotNull(parent.SomeId);
        }
예제 #54
0
        public void TestIntRangePlugin()
        {
            var filler = new Filler<CollectionizerPoco>();

            filler.Setup()
                .OnProperty(x => x.IntRange)
                .Use(new Collectionizer<int, IntRange>(new IntRange(10, 15), 3, 10));

            var collection = filler.Create();
            Assert.True(collection.IntRange.Count >= 3 && collection.IntRange.Count() <= 10);
            Assert.True(collection.IntRange.All(x => x >= 10 && x <= 15));
        }
예제 #55
0
        public void TestFillLibraryWithSimpleTypes()
        {
            Filler<LibraryConstructorWithSimple> lib = new Filler<LibraryConstructorWithSimple>();
            lib.Setup()
                .OnProperty(x => x.Books).IgnoreIt();
            LibraryConstructorWithSimple filledLib = lib.Create();

            Assert.IsNull(filledLib.Books);
            Assert.IsNotNull(filledLib);
            Assert.IsNotNull(filledLib.City);
            Assert.IsNotNull(filledLib.Name);
        }
        public void Test_With_LoremIpsum_Seed_Settings()
        {
            Filler<Book> book = new Filler<Book>();
            book.Setup()
                .OnProperty(x => x.ISBN).Use(new Lipsum(LipsumFlavor.LoremIpsum, seed: 1234));

            var b = book.Create();
            var b1 = book.Create();

            Assert.IsNotNull(b);
            Assert.IsNotNull(b1);
            Assert.AreEqual(b.ISBN, b1.ISBN);
        }
예제 #57
0
        public void SetupCityAndCountryPropertyWithConstantValue()
        {
            Filler<Address> addressFiller = new Filler<Address>();
            addressFiller.Setup()
                .OnProperty(ad => ad.City, ad => ad.Country).Use(() => "CityCountry");
            Address a = addressFiller.Create();

            Assert.AreEqual("CityCountry", a.City);
            Assert.IsNotNull(a.Country);
            Assert.AreNotEqual(0, a.HouseNumber);
            Assert.IsNotNull(a.PostalCode);
            Assert.IsNotNull(a.Street);
        }
예제 #58
0
        public void UseSetupsAgainForTypeConfigurations()
        {
            int givenValue = Randomizer<int>.Create();

            var childFiller = new Filler<Child>();
            var childSetup = childFiller.Setup().OnProperty(x => x.IntValue).Use(givenValue).Result;

            var parentFiller = new Filler<Parent>();
            parentFiller.Setup().OnType<Child>().Use(childSetup);

            var parent = parentFiller.Create();
            Assert.Equal(givenValue, parent.Child.IntValue);
        }
        public void Support(ISpecify specification)
        {
            var filler = new Filler<Person>();
            filler.Setup().OnProperty(x => x.Numbers).IgnoreIt();

            this.AvailablePersons = filler.Create(2);
            var personRepository = specification.GetInstance<IPersonRepository>();

            A.CallTo(() => personRepository.GetAllPersons()).Returns(this.AvailablePersons);

            A.CallTo(() => personRepository.GetPerson(A<int>.Ignored))
                .ReturnsLazily((int id) => this.AvailablePersons.First(p => p.Id == id));
        }
예제 #60
0
        public void TestRealNameLastNameFirstName()
        {
            Filler<LibraryFillingTest.Person> filler = new Filler<LibraryFillingTest.Person>();
            filler.Setup()
                .OnProperty(x => x.Name).Use(new RealNames(RealNameStyle.LastNameFirstName));

            LibraryFillingTest.Person p = filler.Create();

            Assert.IsNotNull(p);
            Assert.IsNotNull(p.Name);
            Assert.IsTrue(p.Name.Contains(" "));
            Assert.AreEqual(2, p.Name.Split(' ').Length);
        }