예제 #1
0
        public void can_generate_random_amount_by_derived_faker()
        {
            var faker = new CustomFaker <Order>()
                        .RuleFor(x => x.Item, f => f.Commerce.Product())
                        .RuleFor(x => x.Quantity, f => f.Random.Number(1, 10))
                        .RuleFor(x => x.OrderId, f => f.UniqueIndex)
                        as CustomFaker <Order>;

            var fakes = faker.Generate(1, 10);

            fakes.Count.Should().BeGreaterOrEqualTo(1).And.BeLessOrEqualTo(10);
            console.Dump(fakes.Count);
        }
예제 #2
0
파일: Issue104.cs 프로젝트: mortware/Bogus
        public void adding_new_property_should_not_change_subsequent_items()
        {
            var faker1 = new CustomFaker <Order>()
                         .RuleFor(o => o.OrderId, f => f.IndexVariable++)
                         .RuleFor(o => o.Item, f => f.Commerce.Product())
                         .RuleFor(o => o.Quantity, f => f.Random.Int(1, 5));

            var orders1 = faker1.Generate(3);

            console.Dump(orders1);
            CheckSequence(orders1);

            var faker2 = new CustomFaker <Order2>()
                         .RuleFor(o => o.OrderId, f => f.IndexVariable++)
                         .RuleFor(o => o.Item, f => f.Commerce.Product())
                         .RuleFor(o => o.Quantity, f => f.Random.Int(1, 5))
                         .RuleFor(o => o.Tax, f => f.Random.Int(9, 15));

            var orders2 = faker2.Generate(3);

            console.Dump(orders2);
            CheckSequence(orders2);
        }