コード例 #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
ファイル: EnumTest.cs プロジェクト: jlikens/ObjectFiller.NET
        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);
            }
        }
コード例 #3
0
        public static List <CustomerDto> GetData(int customersCount)
        {
            Filler <CustomerDto> filler = new Filler <CustomerDto>();

            filler.Setup();
            return(filler.Create(customersCount).ToList());
        }
コード例 #4
0
        public static List <CityDto> GetAddresses(int citiesCount)
        {
            Filler <CityDto> filler = new Filler <CityDto>();

            filler.Setup();
            return(filler.Create(citiesCount).ToList());
        }
コード例 #5
0
        public void RecursiveFill_RecursiveType_ThrowsException()
        {
            var filler = new Filler <TestParent>();

            filler.Setup().OnCircularReference().ThrowException();
            Assert.ThrowsException <InvalidOperationException>(() => filler.Create());
        }
コード例 #6
0
ファイル: EnumTest.cs プロジェクト: GothikX/ObjectFiller.NET
		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());
        }
コード例 #12
0
        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();
        }
コード例 #15
0
        public void RecursiveFill_SelfReferencing_Fails()
        {
            var filler = new Filler <TestSelf>();

            filler.Setup().OnCircularReference().ThrowException();
            Assert.ThrowsException <InvalidOperationException>(() => filler.Create());
        }
コード例 #16
0
        private static Filler <Student> CreateStudentFiller()
        {
            var filler = new Filler <Student>();

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

            return(filler);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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
ファイル: GeoServiceTests.cs プロジェクト: hassanhabib/GeoApi
        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);
        }
コード例 #21
0
        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);
        }
コード例 #26
0
        public void IfIgnoreInheritanceIsSetToTrueTheNameOfTheStudentShouldBeNull()
        {
            Filler<Student> filler = new Filler<Student>();
            filler.Setup().IgnoreInheritance();
            var student = filler.Create();

            Assert.Null(student.FirstName);
            Assert.NotNull(student.Class);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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);
        }
コード例 #35
0
        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);
        }
コード例 #36
0
        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);
        }
コード例 #37
0
        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);
        }
コード例 #38
0
        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);
        }
コード例 #39
0
        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);
        }
コード例 #42
0
        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));
        }
コード例 #49
0
        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);
        }
コード例 #50
0
        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);
        }
コード例 #51
0
 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);
        }
コード例 #56
0
        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);
        }
コード例 #59
0
        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);
        }