public void ShouldAddMappingSetForGivenType() { var filler = new Filler(); filler.Configure<Foo>(); Assert.That(filler.MappingSets.Count(), Is.EqualTo(1)); Assert.That(filler.MappingSets.First().Type, Is.EqualTo(typeof(Foo))); }
public static void Main () { var r = new Random (); var objs = new object [9]; var which = 0; var last = new Filler [Bitmaps.NumWhich]; for (var i = 0; i < 1000000000; ++i) { var o = Bitmaps.MakeAndFill (which, objs, r.Next (2) == 0); objs [r.Next (objs.Length)] = o; last [which] = o; if (i % 761 == 0) { var l = last [r.Next (Bitmaps.NumWhich)]; if (l != null) l.Fill (objs); } /* if (i % 10007 == 0) Console.WriteLine (o.GetType ().Name + " " + which); */ if (i % 5 == 0) objs [r.Next (objs.Length)] = null; if (++which >= Bitmaps.NumWhich) which = 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); } }
public void DependencyOrderingWorksWithSubclassesAsWellAsPrimitives() { var rootObject = new Foo(); var filler = new Filler(); var generator = MockRepository.GenerateStub<IGenerateDummyData>(); generator.Stub(g => g.Generate(Arg<GenerationContext>.Is.Anything)).Return("Chris"); var dependentGenerator = MockRepository.GenerateStub<IGenerateDummyData>(); dependentGenerator.Stub(g => g.Generate(Arg<GenerationContext>.Is.Anything)) .Do(new GeneratorDelegate(context => string.Format("Hello {0}", context.RootAs<Foo>().Bar.Name))); filler.Configure<Goo>(config => config.For(goo => goo.Name).Use(dependentGenerator)); filler.Configure<Bar>(config => config.For(goo => goo.Name).Use(generator)); filler.Configure<Foo>(config => { config.For(f => f.Goo).Order(2); config.For(f => f.Bar).Order(1); }); filler.Fill(rootObject); Assert.That(rootObject.Goo.Name, Is.EqualTo("Hello Chris")); }
public void WhenClassWithCopyConstructorIsCreatedNoExceptionShallBeThrown() { var f = new Filler<ClassWithCopyConstructorAndNormalConstructor>(); var cc = f.Create(); Assert.NotNull(cc); }
public void RecursiveFill_WithIgnoredProperties_Succeeds() { var filler = new Filler<TestParent>(); filler.Setup().OnProperty(p => p.Child).IgnoreIt(); var result = filler.Create(); Assert.NotNull(result); }
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 Ensure_that_double_does_not_return_infinity() { var filler = new Filler<MyClass>(); var myClass = filler.Create(); Assert.False(double.IsInfinity(myClass._double)); Assert.False(float.IsInfinity(myClass._float)); }
public void CreateMultipleInstances() { Filler<LibraryFillingTest.Person> filler = new Filler<LibraryFillingTest.Person>(); IEnumerable<LibraryFillingTest.Person> pList = filler.Create(10); Assert.NotNull(pList); Assert.Equal(10, pList.Count()); }
public void Must_be_able_to_handle_inheritance_and_sealed() { var filler = new Filler<InheritedClass>(); var obj = filler.Create(); Assert.NotEqual(0, obj.NormalNumber); Assert.NotEqual(0, obj.OverrideNormalNumber); Assert.NotEqual(0, obj.SealedOverrideNormalNumber); }
public void Clone() { var pFiller = new Filler<Identity>(); var test = pFiller.Create(); var clone = test.Clone(); var compareLogic = new CompareLogic(); var result = compareLogic.Compare(test, clone); Assert.True(result.AreEqual, result.DifferencesString); }
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 AHashsetShouldBeGenerated() { Filler<HashSet<string>> filler = new Filler<HashSet<string>>(); var hashset = filler.Create(); Assert.NotNull(hashset); Assert.True(hashset.Any()); }
public void ParentShallGetFilledWithourError() { Filler<Parent> filler = new Filler<Parent>(); var filledObject = filler.Create(); Assert.NotNull(filledObject); Assert.NotNull(filledObject.MakeTheError); Assert.False(string.IsNullOrWhiteSpace(filledObject.Child.MakeTheError)); }
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.IsNotNull(filledLib.Books); }
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); }
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 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 Ensure_that_each_primitive_datatype_is_mapped_by_default() { var filler = new Filler<MyClass>(); var myClasses = filler.Create(100).ToArray(); foreach (var myClass in myClasses) { Assert.NotEqual(default(Guid), myClass._Guid); Assert.NotEqual(default(decimal), myClass._Decimal); } }
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 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 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); }
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 FillNullableEnum() { var filler = new Filler<ClassWithNullableEnum>(); var c = filler.Create(); Assert.IsTrue( c.NullableEnum == StandardEnum.A || c.NullableEnum == StandardEnum.B || c.NullableEnum == StandardEnum.C); }
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); }
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))); }
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))); }
public void Must_be_able_to_handle_arrays() { var filler = new Filler<WithArrays>(); //.For<int[]>(); var obj = filler.Create(); Assert.IsNotNull(obj.Ints); Assert.IsNotNull(obj.Strings); Assert.IsNotNull(obj.Interfaces); }
public void Clone() { var pFiller = new Filler<Constraint>(); var test = pFiller.Create(); var clone = test.Clone(); var config = new ComparisonConfig(); config.MembersToIgnore.Add("Table"); //table should never be cloned var compareLogic = new CompareLogic(config); var result = compareLogic.Compare(test, clone); Assert.True(result.AreEqual, result.DifferencesString); }
public void FillAllAddressProperties() { Filler<Address> addressFiller = new Filler<Address>(); Address a = addressFiller.Create(); Assert.IsNotNull(a.City); Assert.IsNotNull(a.Country); Assert.AreNotEqual(0, a.HouseNumber); Assert.IsNotNull(a.PostalCode); Assert.IsNotNull(a.Street); }
public void Clone() { var pFiller = new Filler <Constraint>(); var test = pFiller.Create(); var clone = test.Clone(); var config = new ComparisonConfig(); config.MembersToIgnore.Add("Table"); //table should never be cloned var compareLogic = new CompareLogic(config); var result = compareLogic.Compare(test, clone); Assert.True(result.AreEqual, result.DifferencesString); }
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 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 DeleteRowTest() { Filler.AddSetOfProduct(); IProduct iproduct = new Product(); int id = 1; var row = Filler.products[id]; string expectedRow = row.ProductName + " " + row.Description + " " + row.ProductType + " " + row.CurrentPrice; string updateRow = iproduct.DeleteRow(id); Assert.AreEqual(expectedRow, updateRow); }
public void Must_be_able_to_handle_arrays() { var filler = new Filler <WithArrays>(); //.For<int[]>(); var obj = filler.Create(); Assert.NotNull(obj.Ints); Assert.NotNull(obj.Strings); Assert.NotNull(obj.JaggedStrings); Assert.NotNull(obj.ThreeJaggedDimensional); Assert.NotNull(obj.ThreeJaggedPoco); }
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)); }
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)); }
public FillerSetup GetFillerSetup() { Filler <Person> filler = new Filler <Person>(); return(filler.Setup() .OnType <IAddress>().CreateInstanceOf <Address>() .OnProperty(x => x.Age).Use(new IntRange(18, 35)) .OnProperty(x => x.FirstName).Use(new RealNames(NameStyle.FirstName)) .OnProperty(x => x.LastName).Use(new RealNames(NameStyle.LastName)) .SetupFor <Address>() .OnProperty(x => x.HouseNumber).Use(new IntRange(1, 100)) .Result); }
private static void AddFillersToSlots(WidgetLayout layout) { var fillers = new List <Filler>(); foreach (var slot in layout.slots) { var filler = Filler.CreateFromSlot(slot.gameObject); filler.Hide(); fillers.Add(filler); } Fillers[layout.location] = fillers; }
public void GenerateTestDataForASortedList() { Filler <SortedList <int, string> > filler = new Filler <SortedList <int, string> >(); filler.Setup().OnType <int>().Use(Enumerable.Range(1, 1000)); var result = filler.Create(10).ToList(); Assert.Equal(10, result.Count); foreach (var sortedList in result) { Assert.True(sortedList.Any()); } }
private static Filler <Fee> CreateFeeFiller(DateTimeOffset dates) { var filler = new Filler <Fee>(); Guid createdById = Guid.NewGuid(); filler.Setup() .OnType <DateTimeOffset>().Use(dates) .OnProperty(fee => fee.CreatedByUser).IgnoreIt() .OnProperty(fee => fee.UpdatedByUser).IgnoreIt() .OnProperty(fee => fee.ExamFees).IgnoreIt(); return(filler); }
public void TestNameListStringRandomizer() { Filler <Person> pFiller = new Filler <Person>(); pFiller.Setup().OnType <IAddress>().CreateInstanceOf <Address>() .OnProperty(p => p.FirstName).Use(new RealNames(NameStyle.FirstName)) .OnProperty(p => p.LastName).Use(new RealNames(NameStyle.LastName)); Person filledPerson = pFiller.Create(); Assert.IsNotNull(filledPerson.FirstName); Assert.IsNotNull(filledPerson.LastName); }
public void FluentTest() { Filler <Person> pFiller = new Filler <Person>(); pFiller.Setup() .OnProperty(x => x.Age).Use(() => 18) .OnType <IAddress>().CreateInstanceOf <Address>(); Person p = pFiller.Create(); Assert.IsNotNull(p); Assert.AreEqual(18, p.Age); }
private static Filler<Exam> CreateRandomExamFiller(DateTimeOffset dateTime) { var filler = new Filler<Exam>(); filler.Setup() .OnType<DateTimeOffset>().Use(dateTime) .OnProperty(exam => exam.SemesterCourse).IgnoreIt() .OnProperty(exam => exam.StudentExams).IgnoreIt() .OnProperty(exam => exam.ExamAttachments).IgnoreIt() .OnProperty(exam => exam.ExamFees).IgnoreIt(); return filler; }
private static Filler <StudentSemesterCourse> CreateStudentSemesterCourseFiller(DateTimeOffset dates) { var filler = new Filler <StudentSemesterCourse>(); filler.Setup() .OnType <DateTimeOffset>().Use(dates) .OnProperty(semesterCourse => semesterCourse.CreatedDate).Use(dates) .OnProperty(semesterCourse => semesterCourse.UpdatedDate).Use(dates) .OnType <Student>().IgnoreIt() .OnType <SemesterCourse>().IgnoreIt(); return(filler); }
public void Clone() { var pFiller = new Filler <Column>(); pFiller.Setup() .OnType <Identity>().Use(() => new Identity()); var test = pFiller.Create(); var clone = test.Clone(); var compareLogic = new CompareLogic(); var result = compareLogic.Compare(test, clone); Assert.True(result.AreEqual, result.DifferencesString); }
private static Filler <Teacher> CreateRandomTeacherFiller(DateTimeOffset dates) { var filler = new Filler <Teacher>(); filler.Setup() .OnType <DateTimeOffset>().Use(dates) .OnProperty(teacher => teacher.SemesterCourses).IgnoreIt() .OnProperty(teacher => teacher.TeacherContacts).IgnoreIt() .OnProperty(teacher => teacher.ReviewedStudentExams).IgnoreIt() .OnProperty(teacher => teacher.TeacherAttachments).IgnoreIt(); return(filler); }
public void CloneNewName() { var pFiller = new Filler <Column>(); var test = pFiller.Create(); var clone = test.Clone(true); var compareLogic = new CompareLogic(); compareLogic.Config.MembersToIgnore.Add("Name"); var result = compareLogic.Compare(test, clone); Assert.True(result.AreEqual, result.DifferencesString); Assert.NotEqual(test.Default.Name, clone.Default.Name); }
public void TestRealNameFirstNameOnly() { Filler <LibraryFillingTest.Person> filler = new Filler <LibraryFillingTest.Person>(); filler.Setup() .OnProperty(x => x.Name).Use(new RealNames(NameStyle.FirstName)); LibraryFillingTest.Person p = filler.Create(); Assert.IsNotNull(p); Assert.IsNotNull(p.Name); Assert.IsFalse(p.Name.Contains(" ")); }
private static Filler <Assignment> CreateAssignmentFiller(DateTimeOffset dates) { var filler = new Filler <Assignment>(); filler.Setup() .OnProperty(assignment => assignment.Status).Use(AssignmentStatus.Active) .OnProperty(assignment => assignment.CreatedDate).Use(dates) .OnProperty(assignment => assignment.UpdatedDate).Use(dates) .OnProperty(assignment => assignment.Deadline).Use(dates.AddDays(GetRandomNumber())) .OnProperty(assignment => assignment.AssignmentAttachments).IgnoreIt(); return(filler); }
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); }
private static Filler <Contact> CreateRandomContactFiller(DateTimeOffset dateTime) { Filler <Contact> filler = new Filler <Contact>(); filler.Setup() .OnType <DateTimeOffset>().Use(dateTime) .OnProperty(contact => contact.StudentContacts).IgnoreIt() .OnProperty(contact => contact.TeacherContacts).IgnoreIt() .OnProperty(contact => contact.GuardianContacts).IgnoreIt() .OnProperty(contact => contact.UserContacts).IgnoreIt(); return(filler); }
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); }
public void TestIgnoreAllOfComplexType() { Filler <Person> pFiller = new Filler <Person>(); pFiller.Setup() .OnType <IAddress>().CreateInstanceOf <Address>() .OnType <Address>().IgnoreIt() .OnType <IAddress>().IgnoreIt(); Person p = pFiller.Create(); Assert.NotNull(p); Assert.Null(p.Address); }
public void IgnoreCountryAndCity() { Filler <Address> addressFiller = new Filler <Address>(); addressFiller.Setup() .OnProperty(x => x.Country, x => x.City).IgnoreIt(); Address a = addressFiller.Create(); Assert.Null(a.City); Assert.Null(a.Country); Assert.NotEqual(0, a.HouseNumber); Assert.NotNull(a.PostalCode); Assert.NotNull(a.Street); }
public void TestSetupForTypeWithoutOverrideSettings() { Filler <Person> pFiller = new Filler <Person>(); pFiller.Setup() .OnType <IAddress>().CreateInstanceOf <Address>() .OnType <int>().Use(() => 1) .SetupFor <Address>(); Person p = pFiller.Create(); Assert.Equal(1, p.Age); Assert.Equal(1, p.Address.HouseNumber); }
public void TestFillPerson() { Filler <Person> pFiller = new Filler <Person>(); pFiller.Setup() .OnType <IAddress>().CreateInstanceOf <Address>(); Person filledPerson = pFiller.Create(); Assert.NotNull(filledPerson.Address); Assert.NotNull(filledPerson.Addresses); Assert.NotNull(filledPerson.StringToIAddress); Assert.NotNull(filledPerson.SureNames); }
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.Equal("CityCountry", a.City); Assert.NotNull(a.Country); Assert.NotEqual(0, a.HouseNumber); Assert.NotNull(a.PostalCode); Assert.NotNull(a.Street); }
private static Filler <StudentExamFee> CreateStudentExamFeeFiller(DateTimeOffset dates) { var filler = new Filler <StudentExamFee>(); filler.Setup() .OnProperty(studentExamFee => studentExamFee.CreatedDate).Use(dates) .OnProperty(studentExamFee => studentExamFee.UpdatedDate).Use(dates) .OnProperty(studentExamFee => studentExamFee.Student).IgnoreIt() .OnProperty(studentExamFee => studentExamFee.ExamFee).IgnoreIt() .OnProperty(studentExamFee => studentExamFee.CreatedByUser).IgnoreIt() .OnProperty(studentExamFee => studentExamFee.UpdatedByUser).IgnoreIt(); return(filler); }
private static Filler <StudentExam> CreateStudentExamFiller(DateTimeOffset dates) { var filler = new Filler <StudentExam>(); filler.Setup() .OnType <DateTimeOffset>().Use(dates) .OnProperty(StudentExam => StudentExam.CreatedDate).Use(dates) .OnProperty(StudentExam => StudentExam.UpdatedDate).Use(dates) .OnProperty(StudentExam => StudentExam.Student).IgnoreIt() .OnProperty(StudentExam => StudentExam.Exam).IgnoreIt() .OnProperty(StudentExam => StudentExam.ReviewingTeacher).IgnoreIt(); return(filler); }