Exemplo n.º 1
0
        public void BigComplicated()
        {
            Filler <Person> pFiller = new Filler <Person>();

            pFiller.Setup()
            .OnType <IAddress>().CreateInstanceOf <Address>()
            .OnProperty(p => p.LastName, p => p.FirstName).DoIt(At.TheEnd).Use(new RealNames(NameStyle.FirstName))
            .OnProperty(p => p.Age).Use(() => Random.Next(10, 32))
            .SetupFor <Address>()
            .OnProperty(a => a.City).Use(new MnemonicString(1))
            .OnProperty(a => a.Street).IgnoreIt();

            var pF = pFiller.Create();

            Assert.NotNull(pF);
            Assert.NotNull(pF.Address);
            Assert.Null(pF.Address.Street);
        }
Exemplo n.º 2
0
        public void TestFillPerson()
        {
            Person          p      = new Person();
            Filler <Person> filler = new Filler <Person>();

            filler.Setup()
            .OnType <IAddress>().CreateInstanceOf <Address>()
            .OnType <string>().Use(new MnemonicString(10))
            .OnProperty(person => person.FirstName).Use(new MnemonicString(1))
            .OnProperty(person => person.LastName).Use(new RandomListItem <string>("Maik", "Tom", "Anton"))
            .OnProperty(person => person.Age).Use(() => Random.Next(12, 83))
            .SetupFor <Address>()
            .OnProperty(x => x.City, x => x.Country).IgnoreIt();

            Person pFilled = filler.Fill(p);

            Assert.IsTrue(new List <string>()
            {
                "Maik", "Tom", "Anton"
            }.Contains(pFilled.LastName));
        }