コード例 #1
0
        public void DontSupplyAnyCustomConverters()
        {
            CustomConverterConfigurer config = new CustomConverterConfigurer();

            config.CustomConverters = null;
            config.PostProcessObjectFactory(factory);
            mocks.ReplayAll();

            mocks.VerifyAll();
        }
コード例 #2
0
        public void UseInvalidKeyForConverterMapKey()
        {
            IDictionary converters = new Hashtable();

            converters.Add(12, typeof(DateTimeConverter));

            CustomConverterConfigurer config = new CustomConverterConfigurer();

            config.CustomConverters = converters;
            Assert.Throws <ObjectInitializationException>(() => config.PostProcessObjectFactory(factory));
        }
コード例 #3
0
        public void UseNonTypeConverterForConverterMapValue()
        {
            IDictionary converters = new Hashtable();

            converters.Add(typeof(DateTime), null);

            CustomConverterConfigurer config = new CustomConverterConfigurer();

            config.CustomConverters = converters;
            Assert.Throws <ObjectInitializationException>(() => config.PostProcessObjectFactory(factory));
        }
コード例 #4
0
        public void UseNonResolvableTypeForConverterMapKey()
        {
            IDictionary converters = new Hashtable();

            // purposely misspelled... :D
            converters.Add("Systemm.Date", typeof(DateTimeConverter));

            CustomConverterConfigurer config = new CustomConverterConfigurer();

            config.CustomConverters = converters;
            Assert.Throws <ObjectInitializationException>(() => config.PostProcessObjectFactory(factory));
        }
コード例 #5
0
        public void SunnyDayScenario()
        {
            IDictionary       converters        = new Hashtable();
            Type              dateTimeType      = typeof(DateTime);
            DateTimeConverter dateTimeConverter = new DateTimeConverter();
            Type              colorType         = typeof(Color);
            ColorConverter    colorConverter    = new ColorConverter();

            converters.Add(dateTimeType, dateTimeConverter);
            converters.Add(colorType, colorConverter);

            factory.RegisterCustomConverter(dateTimeType, dateTimeConverter);
            factory.RegisterCustomConverter(colorType, colorConverter);

            mocks.ReplayAll();

            CustomConverterConfigurer config = new CustomConverterConfigurer();

            config.CustomConverters = converters;
            config.PostProcessObjectFactory(factory);

            mocks.VerifyAll();
        }