示例#1
0
        public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType()
        {
            try
            {
                IPropertyNamer propertyNamer = mocks.DynamicMock <IPropertyNamer>();

                BuilderSetup.SetPropertyNamerFor <MyClass>(propertyNamer);

                using (mocks.Record())
                {
                    propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf)).Repeat.Once();
                }

                using (mocks.Playback())
                {
                    Builder <MyClass> .CreateListOfSize(10).Build();

                    Builder <SimpleClass> .CreateListOfSize(10).Build();
                }

                mocks.VerifyAll();
            }
            finally
            {
                BuilderSetup.ResetToDefaults();
            }
        }
示例#2
0
        public void SpecifyingACustomPropertyNamerForASpecificType()
        {
            BuilderSetup.SetPropertyNamerFor <Product>(new CustomProductPropertyNamer(new ReflectionUtil()));

            var products = Builder <Product> .CreateListOfSize(10).Build();

            Assert.That(products[0].Location.Aisle, Is.EqualTo('A'));
            Assert.That(products[0].Location.Shelf, Is.EqualTo(2));
            Assert.That(products[0].Location.Location, Is.EqualTo(1000));

            Assert.That(products[9].Location.Aisle, Is.EqualTo('J'));
            Assert.That(products[9].Location.Shelf, Is.EqualTo(20));
            Assert.That(products[9].Location.Location, Is.EqualTo(10000));

            // Reset it afterwards so the other tests work as expected
            BuilderSetup.ResetToDefaults();
        }
示例#3
0
        public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType()
        {
            IPropertyNamer propertyNamer = mocks.DynamicMock <IPropertyNamer>();

            BuilderSetup.SetPropertyNamerFor <MyClass>(propertyNamer);

            using (mocks.Record())
            {
                propertyNamer.Expect(x => x.SetValuesOf(Arg <MyClass> .Is.TypeOf));
            }

            using (mocks.Playback())
            {
                Builder <MyClass> .CreateNew().Build();

                Builder <SimpleClass> .CreateNew().Build();
            }

            mocks.VerifyAll();
        }
示例#4
0
        public ImportacaoTest()
        {
            BuilderSetup.ResetToDefaults();

            var namer = new RandomValuePropertyNamer(
                new RandomGenerator(),
                new ReflectionUtil(),
                true,
                DateTime.Now,
                DateTime.Now.AddDays(10),
                true,
                new BuilderSettings());

            BuilderSetup.SetPropertyNamerFor <Politico>(namer);
            BuilderSetup.DisablePropertyNamingFor <Politico, Importacao>(_ => _.Importacao);
            var random = new Random();

            politicoBuilder = Builder <Politico> .CreateNew()
                              .With(_ => _.DT_ELEICAO, DateTime.Now.AddDays(random.NextDouble() + 100).Date)
                              .With(_ => _.DT_NASCIMENTO, DateTime.Now.AddDays(random.NextDouble() + 100).Date);

            importacaoBuilder = Builder <Importacao> .CreateNew();
        }
示例#5
0
 public void Configuration_3()
 {
     BuilderSetup.SetPropertyNamerFor <Product>(new CustomProductPropertyNamer(new ReflectionUtil()));
 }
        public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType()
        {
            BuilderSetup builderSetup = new BuilderSetup();
            try
            {
                   IPropertyNamer propertyNamer = mocks.DynamicMock<IPropertyNamer>();

                builderSetup.SetPropertyNamerFor<MyClass>(propertyNamer);

                using (mocks.Record())
                {
                    propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg<IList<MyClass>>.Is.TypeOf)).Repeat.Once();
                }

                using (mocks.Playback())
                {
                   new Builder<MyClass>(builderSetup).CreateListOfSize(10).Build();
                   new Builder<SimpleClass>(builderSetup).CreateListOfSize(10).Build();
                }

                mocks.VerifyAll();
            }
            finally
            {
                builderSetup.ResetToDefaults();
            }
        }
        public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType()
        {
            var builderSetup = new BuilderSetup();
            IPropertyNamer propertyNamer = mocks.DynamicMock<IPropertyNamer>();

            builderSetup.SetPropertyNamerFor<MyClass>(propertyNamer);

            using (mocks.Record())
            {
                propertyNamer.Expect(x => x.SetValuesOf(Arg<MyClass>.Is.TypeOf));
            }

            using (mocks.Playback())
            {
                new Builder<MyClass>(builderSetup).CreateNew().Build();
                new Builder<SimpleClass>(builderSetup).CreateNew().Build();
            }

            mocks.VerifyAll();
        }