Exemplo n.º 1
0
        public void SimpleEntity()
        {
            var notZero = false;

            5.Times(() => notZero = notZero || domainGenerator.One <ProductPrice>().Value != 0);
            Assert.True(notZero);
        }
        public void CategoryTest()
        {
            var category = domainGenerator.One <Category>();

            Assert.Equal(2, category.Products.Count);

            Assert.Equal(category, category.Products[0].MyCategory);
            Assert.Equal(category, category.Products[1].MyCategory);
        }
        public void SupplyingStartingValueAndStep()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.Counter(e => e.MyProperty, 5, 2));

            Assert.Equal(5, domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal(7, domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal(9, domainGenerator.One<SomethingToGenerate>().MyProperty);
        }
Exemplo n.º 4
0
        public void SupplyingStartingValueAndStep()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.Counter(e => e.MyProperty, 5, 2));

            Assert.Equal(5, domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal(7, domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal(9, domainGenerator.One <SomethingToGenerate>().MyProperty);
        }
        public void SimpleAppend()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.Counter(e => e.MyProperty));

            Assert.Equal(1, domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal(2, domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal(3, domainGenerator.One<SomethingToGenerate>().MyProperty);
        }
        public void SupplyingFullValue()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty, () => "SomeString"));

            Assert.Equal("SomeString1", domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString2", domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString3", domainGenerator.One<SomethingToGenerate>().MyProperty);
        }
Exemplo n.º 7
0
        public void SupplyingFullValue()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty, () => "SomeString"));

            Assert.Equal("SomeString1", domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString2", domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString3", domainGenerator.One <SomethingToGenerate>().MyProperty);
        }
Exemplo n.º 8
0
        public void SimpleAppend()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.Counter(e => e.MyProperty));

            Assert.Equal(1, domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal(2, domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal(3, domainGenerator.One <SomethingToGenerate>().MyProperty);
        }
Exemplo n.º 9
0
        public void CounterOnly()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty));

            // the value starts with a random string, and :
            Assert.True(domainGenerator.One <SomethingToGenerate>().MyProperty.EndsWith("1"));
            Assert.True(domainGenerator.One <SomethingToGenerate>().MyProperty.EndsWith("2"));
            Assert.True(domainGenerator.One <SomethingToGenerate>().MyProperty.EndsWith("3"));
        }
        public void CounterOnly()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty));

            // the value starts with a random string, and :
            Assert.True(domainGenerator.One<SomethingToGenerate>().MyProperty.EndsWith("1"));
            Assert.True(domainGenerator.One<SomethingToGenerate>().MyProperty.EndsWith("2"));
            Assert.True(domainGenerator.One<SomethingToGenerate>().MyProperty.EndsWith("3"));
        }
        public void SimpleAppend()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.For(e => e.MyProperty, "SomeString"))
                    .With<SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty));

            Assert.Equal("SomeString1", domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString2", domainGenerator.One<SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString3", domainGenerator.One<SomethingToGenerate>().MyProperty);
        }
Exemplo n.º 12
0
        public void SimpleAppend()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.For(e => e.MyProperty, "SomeString"))
                .With <SomethingToGenerate>(g => g.AppendCounter(e => e.MyProperty));

            Assert.Equal("SomeString1", domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString2", domainGenerator.One <SomethingToGenerate>().MyProperty);
            Assert.Equal("SomeString3", domainGenerator.One <SomethingToGenerate>().MyProperty);
        }
        public void JustWorks()
        {
            var product1 = domainGenerator.One <Product>();

            Assert.Equal(1, product1.Id);

            var product2 = domainGenerator.One <Product>();

            Assert.Equal(2, product2.Id);

            var product3 = domainGenerator.One <Product>();

            Assert.Equal(3, product3.Id);
        }
        public void GeneratorIsApplied()
        {
            var is42 = false;
            var is43 = false;

            20.Times(
                () =>
            {
                is42 = is42 || domainGenerator.One <Product>().Id == 42;
                is43 = is43 || domainGenerator.One <Product>().Id == 43;
            });

            Assert.True(is42);
            Assert.True(is43);
        }
Exemplo n.º 15
0
 public void AreMemberWiseEqual()
 {
     var generator =
         new DomainGenerator()
             .With(42)
             .OneToMany<Something, SomethingElse>(3, (s, se) => s.MySomethingElse.Add(se));
     var thingOne = generator.One<Something>();
     var thingTwo = generator.One<Something>();
     var inspector =
         Inspect
             .This(thingOne, thingTwo)
             .Inspect<Something, SomethingElse>(s => s.MySomethingElse);
     Assert.True(inspector.AreMemberWiseEqual());
     thingTwo.MySomethingElse[1].MyProp = 43;
     Assert.False(inspector.AreMemberWiseEqual());
 }
Exemplo n.º 16
0
 public void CompositeTests()
 {
     var generator =
         new DomainGenerator()
             .With(42)
             .Component<SomethingElse>();
     var thingOne = generator.One<Something>();
     var thingTwo = generator.One<Something>();
     var inspector =
         Inspect
             .This(thingOne, thingTwo)
             .Inspect<Something, SomethingElse>(s => s.MySomethingElse);
     Assert.True(inspector.AreMemberWiseEqual());
     thingTwo.MySomethingElse.MyProp = 43;
     Assert.False(inspector.AreMemberWiseEqual());
 }
 public void Generator()
 {
     var generator =
         new DomainGenerator()
             .With<SomethingToGenerate>(opt => opt.Construct<int>(new IntGenerator(42, 42)));
     Assert.Equal(42, generator.One<SomethingToGenerate>().CheckInt());
 }
Exemplo n.º 18
0
        public override void Arrange()
        {
            domainGenerator =
                new DomainGenerator()
                // Zero throws nullreference somehow !
                .OneToMany <LevelOne, LevelTwo>(1, 10, (one, many) => { one.NextLevel.Add(many); many.Parent = one; })
                .OneToMany <LevelTwo, LevelThree>(1, 10, (one, many) => { one.NextLevel.Add(many); many.Parent = one; });

            action =
                new Func <ILevel>[]
            {
                () => domainGenerator.One <LevelOne>(),
                () => domainGenerator.One <LevelTwo>(),
                () => domainGenerator.One <LevelThree>()
            }.PickOne();
        }
 public void PossibleValue()
 {
     var generator =
         new DomainGenerator()
             .With<SomethingToGenerate>(opt => opt.Construct(42));
     Assert.Equal(42, generator.One<SomethingToGenerate>().CheckInt());
 }
        public void UsesDefaultValue()
        {
            var generator =
                new DomainGenerator().With(() => new SomethingToGenerate(42));

            Assert.Equal(42, generator.One <SomethingToGenerate>().GetInt());
        }
Exemplo n.º 21
0
        public void StaysDefaultvalue()
        {
            10.Times(
                () =>
            {
                var product = domainGenerator.One <Product>();
                Assert.Equal(0, product.Id);
            });

            10.Times(
                () =>
            {
                var category = domainGenerator.One <Category>();
                Assert.Equal(null, category.Id);
            });
        }
Exemplo n.º 22
0
        public void PossibleValue()
        {
            var generator =
                new DomainGenerator()
                .With <SomethingToGenerate>(opt => opt.Construct(42));

            Assert.Equal(42, generator.One <SomethingToGenerate>().CheckInt());
        }
Exemplo n.º 23
0
        public void CompositeTests()
        {
            var generator =
                new DomainGenerator()
                .With(42)
                .Component <SomethingElse>();
            var thingOne  = generator.One <Something>();
            var thingTwo  = generator.One <Something>();
            var inspector =
                Inspect
                .This(thingOne, thingTwo)
                .Inspect <Something, SomethingElse>(s => s.MySomethingElse);

            Assert.True(inspector.AreMemberWiseEqual());
            thingTwo.MySomethingElse.MyProp = 43;
            Assert.False(inspector.AreMemberWiseEqual());
        }
Exemplo n.º 24
0
        public void Generator()
        {
            var generator =
                new DomainGenerator()
                .With <SomethingToGenerate>(opt => opt.Construct <int>(new IntGenerator(42, 42)));

            Assert.Equal(42, generator.One <SomethingToGenerate>().CheckInt());
        }
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator();
                    //.With(mi => mi.Name == "Value", new IntGenerator(42, 42));

            Assert.Equal(42, domainGenerator.One<SomethingToGenerate>().Value);
        }
Exemplo n.º 26
0
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator()
                .ForPrimitive(new IntGenerator(42, 42));

            Assert.Equal(42, domainGenerator.One <SomethingToGenerate>().Value);
        }
Exemplo n.º 27
0
        public void AreMemberWiseEqual()
        {
            var generator =
                new DomainGenerator()
                .With(42)
                .OneToMany <Something, SomethingElse>(3, (s, se) => s.MySomethingElse.Add(se));
            var thingOne  = generator.One <Something>();
            var thingTwo  = generator.One <Something>();
            var inspector =
                Inspect
                .This(thingOne, thingTwo)
                .Inspect <Something, SomethingElse>(s => s.MySomethingElse);

            Assert.True(inspector.AreMemberWiseEqual());
            thingTwo.MySomethingElse[1].MyProp = 43;
            Assert.False(inspector.AreMemberWiseEqual());
        }
Exemplo n.º 28
0
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator()
                    .ForPrimitive(new IntGenerator(42, 42));

            Assert.Equal(42, domainGenerator.One<SomethingToGenerate>().Value);
        }
Exemplo n.º 29
0
        public void OneToOneShouldThrow()
        {
            var generator =
                new DomainGenerator()
                .OneToOne <Something, SomethingElse>((s, se) => s.MySomethingElse = se);

            Assert.Throws <RecursiveRelationDefinedException>(() => generator.One <Something>());
        }
        public void OneToOneShouldThrow()
        {
            var generator =
                new DomainGenerator()
                    .OneToOne<Something, SomethingElse>((s, se) => s.MySomethingElse = se);

            Assert.Throws<RecursiveRelationDefinedException>(() => generator.One<Something>());
        }
Exemplo n.º 31
0
        public void UnidirectionalOneToOne()
        {
            var generator = new DomainGenerator()
                .OneToOne<Something, SomethingElse>((l, r) => l.MySomethingElse = r);

            var notZero = false;
            5.Times(() => notZero = notZero || generator.One<Something>().MySomethingElse.Value != 0);
            Assert.True(notZero);
        }
Exemplo n.º 32
0
        public void NoChangePossible_Throws()
        {
            var repository = new DomainGenerator().With(true);

            var something = repository.One <WithBoolProperty>();

            Assert.Throws <HeyITriedFiftyTimesButCouldNotGetADifferentValue>(
                () => repository.ModifyThis(something).Change(e => e.MyPropery));
        }
Exemplo n.º 33
0
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator();

            //.With(mi => mi.Name == "Value", new IntGenerator(42, 42));

            Assert.Equal(42, domainGenerator.One <SomethingToGenerate>().Value);
        }
        public void GeneratorIsApplied()
        {
            var generator =
                new DomainGenerator()
                    .WithStringNameCounterPattern();

            var something1 = generator.One<SomethingToGenerate>();
            Assert.Equal("SomeString1", something1.SomeString);
            Assert.Equal("MyString1", something1.MyString);

            var something2 = generator.One<SomethingToGenerate>();
            Assert.Equal("SomeString2", something2.SomeString);
            Assert.Equal("MyString2", something2.MyString);

            var something3 = generator.One<SomethingToGenerate>();
            Assert.Equal("SomeString3", something3.SomeString);
            Assert.Equal("MyString3", something3.MyString);
        }
Exemplo n.º 35
0
        public void UnidirectionalOneToOne()
        {
            var generator = new DomainGenerator()
                            .OneToOne <Something, SomethingElse>((l, r) => l.MySomethingElse = r);

            var notZero = false;

            5.Times(() => notZero = notZero || generator.One <Something>().MySomethingElse.Value != 0);
            Assert.True(notZero);
        }
Exemplo n.º 36
0
        public void Works()
        {
            var domainGenerator =
                new DomainGenerator()
                    .ManyToOne<Child, Parent>(2, (c, p) => p.Add(c))
                    .OneToMany<Parent, Child>(2, (p, c) => p.Add(c));

            var child = domainGenerator.One<Child>();
            Assert.NotNull(child);
            Assert.NotNull(child.MyParent);
            Assert.Equal(2, child.MyParent.Children.Count);
            Assert.Contains(child, child.MyParent.Children);

            var parent = domainGenerator.One<Parent>();
            Assert.NotNull(parent);
            Assert.Equal(2, parent.Children.Count);
            Assert.Equal(parent, parent.Children[0].MyParent);
            Assert.Equal(parent, parent.Children[1].MyParent);
        }
Exemplo n.º 37
0
 public void UsingDomainGenerator()
 {
     var generator = new DomainGenerator();
     100.Times(() =>
                   {
                       var something = generator.One<SomethingToGenerate>();
                       Assert.NotEqual(0, something.PropOne);
                       Assert.NotEqual(0, something.PropTwo);
                   });
 }
 public void Generating_Parent()
 {
     var domainGenerator =
         new DomainGenerator()
             .OneToMany<SomeParent, SomeChild>(1, (one, many) => one.Children.Add(many))
             .OneToMany<SomeParent, SomeChild>(1, (one, many) => one.OtherChildren.Add(many));
     var something = domainGenerator.One<SomeParent>();
     Assert.Equal(1, something.Children.Count);
     Assert.Equal(1, something.OtherChildren.Count);
     Assert.Equal(3, ((DomainGenerator)domainGenerator).GeneratedObjects.Count());
 }
Exemplo n.º 39
0
        public void UsingDomainGenerator()
        {
            var generator = new DomainGenerator();

            100.Times(() =>
            {
                var something = generator.One <SomethingToGenerate>();
                Assert.NotEqual(0, something.PropOne);
                Assert.NotEqual(0, something.PropTwo);
            });
        }
        public void GeneratorIsApplied()
        {
            var generator =
                new DomainGenerator()
                .WithStringNameCounterPattern();

            var something1 = generator.One <SomethingToGenerate>();

            Assert.Equal("SomeString1", something1.SomeString);
            Assert.Equal("MyString1", something1.MyString);

            var something2 = generator.One <SomethingToGenerate>();

            Assert.Equal("SomeString2", something2.SomeString);
            Assert.Equal("MyString2", something2.MyString);

            var something3 = generator.One <SomethingToGenerate>();

            Assert.Equal("SomeString3", something3.SomeString);
            Assert.Equal("MyString3", something3.MyString);
        }
Exemplo n.º 41
0
        public void Generating_Parent()
        {
            var domainGenerator =
                new DomainGenerator()
                .OneToMany <SomeParent, SomeChild>(1, (one, many) => one.Children.Add(many))
                .OneToMany <SomeParent, SomeChild>(1, (one, many) => one.OtherChildren.Add(many));
            var something = domainGenerator.One <SomeParent>();

            Assert.Equal(1, something.Children.Count);
            Assert.Equal(1, something.OtherChildren.Count);
            Assert.Equal(3, ((DomainGenerator)domainGenerator).GeneratedObjects.Count());
        }
Exemplo n.º 42
0
        public void Works()
        {
            var domainGenerator =
                new DomainGenerator()
                .ManyToOne <Child, Parent>(2, (c, p) => p.Add(c))
                .OneToMany <Parent, Child>(2, (p, c) => p.Add(c));

            var child = domainGenerator.One <Child>();

            Assert.NotNull(child);
            Assert.NotNull(child.MyParent);
            Assert.Equal(2, child.MyParent.Children.Count);
            Assert.Contains(child, child.MyParent.Children);

            var parent = domainGenerator.One <Parent>();

            Assert.NotNull(parent);
            Assert.Equal(2, parent.Children.Count);
            Assert.Equal(parent, parent.Children[0].MyParent);
            Assert.Equal(parent, parent.Children[1].MyParent);
        }
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(g => g.Range(e => e.MyProperty, 3, 10));

            10.Times(
                () =>
                    {
                        var something = domainGenerator.One<SomethingToGenerate>();
                        Assert.True(something.MyProperty <= 10);
                        Assert.True(something.MyProperty >= 3);
                    });
        }
Exemplo n.º 44
0
        public void IsApplied()
        {
            var spy = new ForEachSpy();

            var domainGenerator =
                new DomainGenerator()
                    .OneToMany<SomethingElseToGenerate, SomethingToGenerate>(
                        1, (l, r) => { l.SomethingToGenerates.Add(r); r.MySomethingElseToGenerate = l; })
                    .ForEach<IThing>(spy.Check);

            var somethingElseToGenerate = domainGenerator.One<SomethingElseToGenerate>();
            Assert.True(spy.Checked.Contains(somethingElseToGenerate));
            Assert.True(spy.Checked.Contains(somethingElseToGenerate.SomethingToGenerates.First()));
        }
Exemplo n.º 45
0
        public void GeneratorIsApplied()
        {
            var domainGenerator =
                new DomainGenerator()
                .With <SomethingToGenerate>(g => g.Range(e => e.MyProperty, 3, 10));

            10.Times(
                () =>
            {
                var something = domainGenerator.One <SomethingToGenerate>();
                Assert.True(something.MyProperty <= 10);
                Assert.True(something.MyProperty >= 3);
            });
        }
Exemplo n.º 46
0
        public void IsApplied()
        {
            var spy = new ForEachSpy();

            var domainGenerator =
                new DomainGenerator()
                .OneToMany <SomethingElseToGenerate, SomethingToGenerate>(
                    1, (l, r) => { l.SomethingToGenerates.Add(r); r.MySomethingElseToGenerate = l; })
                .ForEach <BaseThing <int> >(spy.Check);

            var somethingElseToGenerate = domainGenerator.One <SomethingElseToGenerate>();

            Assert.True(spy.Checked.Contains(somethingElseToGenerate));
            Assert.True(spy.Checked.Contains(somethingElseToGenerate.SomethingToGenerates.First()));
        }
        public void PossibleValues()
        {
            var generator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(opt => opt.Construct(42, 43));

            var is42 = false;
            var is43 = false;
            20.Times(
                () =>
                {
                    var something = generator.One<SomethingToGenerate>();
                    is42 = is42 || something.CheckInt() == 42;
                    is43 = is43 || something.CheckInt() == 43;
                });
            Assert.True(is42);
            Assert.True(is43);
        }
Exemplo n.º 48
0
 public void HandlesNullables()
 {
     var domainGenerator =
         new DomainGenerator()
             .ForPrimitive(new IntGenerator(42, 42));
     var is42 = false;
     var isNull = false;
     30.Times(() =>
              	{
              		var value = domainGenerator.One<SomethingElseToGenerate>().Value;
                     if (value.HasValue)
                         is42 = is42 || value.Value == 42;
                     else
                         isNull = true;
              	});
     Assert.True(is42);
     Assert.True(isNull);
 }
Exemplo n.º 49
0
        public void PossibleValues()
        {
            var generator =
                new DomainGenerator()
                .With <SomethingToGenerate>(opt => opt.Construct(42, 43));

            var is42 = false;
            var is43 = false;

            20.Times(
                () =>
            {
                var something = generator.One <SomethingToGenerate>();
                is42          = is42 || something.CheckInt() == 42;
                is43          = is43 || something.CheckInt() == 43;
            });
            Assert.True(is42);
            Assert.True(is43);
        }
Exemplo n.º 50
0
        public void GeneratorIsApplied()
        {
            var generator =
                new DomainGenerator()
                    .With(42)
                    .With<Base>(opt => opt.Use<Base>().Use<DerivedOne>().Use<DerivedTwo>());

            var isBase = false;
            var isDerivedOne = false;
            var isDerivedTwo = false;

            100.Times(
                () =>
                    {
                        var thing = generator.One<Base>();
                        if (thing.GetType() == typeof(Base))
                        {
                            isBase = true;
                            Assert.Equal(42, thing.BaseProp);
                        }

                        if (thing.GetType() == typeof(DerivedOne))
                        {
                            var derived = (DerivedOne)thing;
                            isDerivedOne = true;
                            Assert.Equal(42, derived.BaseProp);
                            Assert.Equal(42, derived.DerivedProp);
                        }

                        if (thing.GetType() == typeof(DerivedTwo))
                        {
                            var derived = (DerivedTwo)thing;
                            isDerivedTwo = true;
                            Assert.Equal(42, derived.BaseProp);
                            Assert.Equal(42, derived.DerivedProp);
                            Assert.Equal(42, derived.OtherDerivedProp);
                        }
                    });

            Assert.True(isBase);
            Assert.True(isDerivedOne);
            Assert.True(isDerivedTwo);
        }
Exemplo n.º 51
0
        public void GeneratorIsApplied()
        {
            var generator =
                new DomainGenerator()
                .With(42)
                .With <Base>(opt => opt.Use <Base>().Use <DerivedOne>().Use <DerivedTwo>());

            var isBase       = false;
            var isDerivedOne = false;
            var isDerivedTwo = false;

            100.Times(
                () =>
            {
                var thing = generator.One <Base>();
                if (thing.GetType() == typeof(Base))
                {
                    isBase = true;
                    Assert.Equal(42, thing.BaseProp);
                }

                if (thing.GetType() == typeof(DerivedOne))
                {
                    var derived  = (DerivedOne)thing;
                    isDerivedOne = true;
                    Assert.Equal(42, derived.BaseProp);
                    Assert.Equal(42, derived.DerivedProp);
                }

                if (thing.GetType() == typeof(DerivedTwo))
                {
                    var derived  = (DerivedTwo)thing;
                    isDerivedTwo = true;
                    Assert.Equal(42, derived.BaseProp);
                    Assert.Equal(42, derived.DerivedProp);
                    Assert.Equal(42, derived.OtherDerivedProp);
                }
            });

            Assert.True(isBase);
            Assert.True(isDerivedOne);
            Assert.True(isDerivedTwo);
        }
Exemplo n.º 52
0
        public void GeneratorIsApplied()
        {
            var generator =
                new DomainGenerator()
                    .With(new SomethingToGenerate { MyProperty = 42 }, new SomethingToGenerate { MyProperty = 43 })
                    .With<SomethingToGenerate>(opt => opt.Ignore(e => e.MyProperty)); //otherwise our 42 will be overridden

            var is42 = false;
            var is43 = false;
            20.Times(
                () =>
                    {
                        var something = generator.One<SomethingToGenerate>();
                        is42 = is42 || something.MyProperty == 42;
                        is43 = is43 || something.MyProperty == 43;
                    });
            Assert.True(is42);
            Assert.True(is43);
        }
Exemplo n.º 53
0
        public void GeneratorIsApplied()
        {
            var generator = new DomainGenerator();

            var first  = false;
            var second = false;
            var third  = false;

            100.Times(
                () =>
            {
                var something = generator.One <SomethingToGenerate>();
                first         = first || something.Property == AnEnum.First;
                second        = second || something.Property == AnEnum.Second;
                third         = third || something.Property == AnEnum.Third;
            });

            Assert.True(first);
            Assert.True(second);
            Assert.True(third);
        }
Exemplo n.º 54
0
        public void GeneratorIsApplied()
        {
            var generator = new DomainGenerator();

            var first = false;
            var second = false;
            var third = false;

            100.Times(
                () =>
                    {
                        var something = generator.One<SomethingToGenerate>();
                        first = first || something.Property == AnEnum.First;
                        second = second || something.Property == AnEnum.Second;
                        third = third || something.Property == AnEnum.Third;
                    });

            Assert.True(first);
            Assert.True(second);
            Assert.True(third);
        }
Exemplo n.º 55
0
        public void IgnoreAlwaysWins()
        {
            var generator =
                new DomainGenerator()
                    .With<SomethingToGenerate>(opt => opt.For(e => e.MyProperty, 666))
                    .With<SomethingToGenerate>(opt => opt.Ignore(e => e.MyProperty));

            var isIgnored = false;
            var is666 = false;
            var isSomethingElse = false;

            100.Times(
                () =>
                {
                    var thing = generator.One<SomethingToGenerate>();
                    isIgnored = thing.MyProperty == 0;
                    is666 = thing.MyProperty == 666;
                    isSomethingElse = thing.MyProperty != 0 && thing.MyProperty != 666;
                });

            Assert.True(isIgnored);
            Assert.False(is666);
            Assert.False(isSomethingElse);
        }
Exemplo n.º 56
0
        public void FirstOneWins()
        {
            var generator =
                new DomainGenerator()
                    .With(42)
                    .With(666);

            var is42 = false;
            var is666 = false;
            var isSomethingElse = false;

            100.Times(
                () =>
                    {
                        var thing = generator.One<SomethingToGenerate>();
                        is42 = thing.MyProperty == 42;
                        is666 = thing.MyProperty == 666;
                        isSomethingElse = thing.MyProperty != 42 && thing.MyProperty != 666;
                    });

            Assert.True(is42);
            Assert.False(is666);
            Assert.False(isSomethingElse);
        }
Exemplo n.º 57
0
        public override void Arrange()
        {
            domainGenerator =
                new DomainGenerator()
                // Zero throws nullreference somehow !
                .OneToMany<LevelOne, LevelTwo>(1, 10, (one, many) => { one.NextLevel.Add(many); many.Parent = one; })
                .OneToMany<LevelTwo, LevelThree>(1, 10, (one, many) => { one.NextLevel.Add(many); many.Parent = one; });

            action =
                new Func<ILevel>[]
                    {
                        () => domainGenerator.One<LevelOne>(),
                        () => domainGenerator.One<LevelTwo>(),
                        () => domainGenerator.One<LevelThree>()
                    }.PickOne();
        }