Exemple #1
0
        public void Should_Create_Variation_Of_Specified_Type()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf <Person>(new { FirstName = "" });
            plant.DefineVariationOf <Person>("My", new { FirstName = "My" });
            plant.DefineVariationOf <Person>("Her", new { FirstName = "Her" });

            Assert.IsInstanceOf(typeof(Person), plant.Create <Person>());
            Assert.IsInstanceOf(typeof(Person), plant.Create <Person>("My"));
            Assert.IsInstanceOf(typeof(Person), plant.Create <Person>("Her"));
        }
 public void SetupPlant(BasePlant p)
 {
     p.DefineVariationOf <Customer>("with_sequence", new
     {
         Name = new Sequence <string>(sequenceValue => "Customer " + sequenceValue)
     });
 }
Exemple #3
0
        public void Should_Create_Variation_Of_Specified_Type_With_Correct_Data()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf <Person>(new { FirstName = "" });
            plant.DefineVariationOf <Person>("My", new { FirstName = "My" });

            var person = plant.Create <Person>("My");

            Assert.AreEqual("My", person.FirstName);
        }
        public void CreateVariations()
        {
            plant.DefineVariationOf <House>("appartment", new { SquareFoot = 400 });
            var houses = plant.CreateListOf <House>(3, variation: "appartment");

            foreach (var house in houses)
            {
                Assert.That(house.Color, Is.EqualTo("Red"));
                Assert.That(house.SquareFoot, Is.EqualTo(400));
            }
        }
Exemple #5
0
        public void Should_Create_Variation_With_Extension()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf <House>(new House {
                Color = "blue"
            }, OnPropertyPopulation);
            plant.DefineVariationOf <House>("My", new House {
                Color = "My"
            }, OnPropertyPopulationVariatoion);

            Assert.AreEqual(plant.Create <House>().Persons.First().FirstName, "Pablo");
            Assert.AreEqual(plant.Create <House>("My").Persons.First().FirstName, "Pedro");
        }
Exemple #6
0
        public void Create_WhenVariationHasLazyPropertyOverwrittenByUser_DoesNotInvokeVariationLazyProperty()
        {
            var plant = new BasePlant();
            const string variationName = "Self";
            var wasVariantLazyPropertyAssigned = false;
            plant.DefinePropertiesOf<Person>(new { FirstName = "default" });
            plant.DefineVariationOf<Person>(variationName, new
            {
                FirstName = new LazyProperty<string>(() =>
                {
                    wasVariantLazyPropertyAssigned = true;
                    return "overwritten";
                })
            });

            plant.Create<Person>(new { FirstName = "UserDefined" }, variationName);

            Assert.IsFalse(wasVariantLazyPropertyAssigned);
        }
Exemple #7
0
        public void Should_Create_Variation_With_Extension()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue" }, OnPropertyPopulation);
            plant.DefineVariationOf("My", new House { Color = "My" }, OnPropertyPopulationVariatoion);

            Assert.AreEqual(plant.Create<House>().Persons.First().FirstName, "Pablo");
            Assert.AreEqual(plant.Create<House>("My").Persons.First().FirstName, "Pedro");
        }
Exemple #8
0
        public void Should_Create_Variation_Of_Specified_Type_With_Correct_Data()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf<Person>(new { FirstName = "" });
            plant.DefineVariationOf<Person>("My", new { FirstName = "My" });

            var person = plant.Create<Person>("My");
            Assert.AreEqual("My", person.FirstName);
        }
Exemple #9
0
        public void Should_Create_Variation_Of_Specified_Type()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf<Person>(new { FirstName = "" });
            plant.DefineVariationOf<Person>("My", new { FirstName = "My" });
            plant.DefineVariationOf<Person>("Her", new { FirstName = "Her" });

            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>());
            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>("My"));
            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>("Her"));
        }
Exemple #10
0
 public void SetupPlant(BasePlant p)
 {
     p.DefineVariationOf <House>("appartment", new { Color = "blue" });
 }