コード例 #1
0
        public void Constructing_AssignsValuesToProperties()
        {
            using (mocks.Record())
                propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf));

            var list = new List <MyClass>();

            var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings());

            using (mocks.Playback())
                builder.Name(list);
        }
コード例 #2
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();
            }
        }
コード例 #3
0
        public void ShouldBeAbleToUseANamingStrategy()
        {
            IPropertyNamer propertyNamer = MockRepository.GenerateMock <IPropertyNamer>();

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

            using (mocks.Playback())
            {
                builder.WithPropertyNamer(propertyNamer);
                builder.Name(new MyClass());
            }
        }
コード例 #4
0
        public void ShouldBeAbleToUseBuild()
        {
            var            myClass       = new MyClass();
            IPropertyNamer propertyNamer = MockRepository.GenerateMock <IPropertyNamer>();

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

            using (mocks.Playback())
            {
                builder.WithPropertyNamer(propertyNamer);
                builder.With(x => x.Float = 2f);
                builder.Build();
            }
        }
コード例 #5
0
        public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType()
        {
            var            builderSetup  = new BuilderSettings();
            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(builderSetup).CreateNew <MyClass>().Build();
                new Builder(builderSetup).CreateNew <SimpleClass>().Build();
            }

            mocks.VerifyAll();
        }