本文整理汇总了C#中Filler类的典型用法代码示例。如果您正苦于以下问题:C# Filler类的具体用法?C# Filler怎么用?C# Filler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Filler类属于命名空间,在下文中一共展示了Filler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldAddMappingSetForGivenType
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)));
}
示例2: 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);
}
}
示例3: Main
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;
}
}
示例4: WhenClassWithCopyConstructorIsCreatedNoExceptionShallBeThrown
public void WhenClassWithCopyConstructorIsCreatedNoExceptionShallBeThrown()
{
var f = new Filler<ClassWithCopyConstructorAndNormalConstructor>();
var cc = f.Create();
Assert.NotNull(cc);
}
示例5: DependencyOrderingWorksWithSubclassesAsWellAsPrimitives
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"));
}
示例6: CreateMultipleInstances
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());
}
示例7: Ensure_that_double_does_not_return_infinity
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));
}
示例8: 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);
}
示例9: 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);
}
示例10: ParentShallGetFilledWithourError
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));
}
示例11: Clone
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);
}
示例12: 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);
}
示例13: Must_be_able_to_handle_inheritance_and_sealed
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);
}
示例14: AHashsetShouldBeGenerated
public void AHashsetShouldBeGenerated()
{
Filler<HashSet<string>> filler = new Filler<HashSet<string>>();
var hashset = filler.Create();
Assert.NotNull(hashset);
Assert.True(hashset.Any());
}
示例15: 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);
}