本文整理汇总了C#中Filler.Setup方法的典型用法代码示例。如果您正苦于以下问题:C# Filler.Setup方法的具体用法?C# Filler.Setup怎么用?C# Filler.Setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filler
的用法示例。
在下文中一共展示了Filler.Setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Must_support_enums_out_of_the_box
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);
}
}
示例2: RecursiveFill_WithFunc_Succeeds
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);
}
示例3: RecursiveFill_WithIgnoredProperties_Succeeds
public void RecursiveFill_WithIgnoredProperties_Succeeds()
{
var filler = new Filler<TestParent>();
filler.Setup().OnProperty(p => p.Child).IgnoreIt();
var result = filler.Create();
Assert.NotNull(result);
}
示例4: IfIgnoreInheritanceIsSetToTrueTheNameOfTheStudentShouldBeNull
public void IfIgnoreInheritanceIsSetToTrueTheNameOfTheStudentShouldBeNull()
{
Filler<Student> filler = new Filler<Student>();
filler.Setup().IgnoreInheritance();
var student = filler.Create();
Assert.Null(student.FirstName);
Assert.NotNull(student.Class);
}
示例5: TestFillLibraryWithPocoOfABook
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);
}
示例6: TestFillLibraryWithDictionary
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);
}
示例7: UseSavedFillerDefaultSetup
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);
}
示例8: Test_With_France_High_Values_Settings
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);
}
示例9: IfIgnoreInheritanceIsSetToFalseTheNameOfTheStudentShouldNotBeNull
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);
}
示例10: RandomizerCreatesObjectsBasedOnPreviouseSetups
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);
}
示例11: Test_With_Many_MinWords_And_Many_MinSentences
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);
}
示例12: Test_With_German_Default_Settings
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);
}
示例13: WhenGettingDatesBetweenNowAnd31DaysAgo
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)));
}
示例14: WhenConstructorWithDateTimeNowWillBeCalledNoExceptionShouldBeThrown
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);
}
示例15: WhenStartDateIsBiggerThenEndDateTheDatesShouldBeSwitched
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)));
}