Esempio n. 1
0
        private void EnumTestInternal <TFrom, TTo>()
        {
            AdvancedConverter <TFrom, TTo> advancedConverter         = AdvancedConverter <TFrom, TTo> .Default;
            AdvancedConverter <TTo, TFrom> backwardAdvancedConverter = AdvancedConverter <TTo, TFrom> .Default;
            IInstanceGenerator <TFrom>     instanceGenerator         = InstanceGeneratorProvider.Default.GetInstanceGenerator <TFrom>();

            Assert.IsNotNull(advancedConverter);
            Assert.IsNotNull(backwardAdvancedConverter);
            Assert.IsNotNull(instanceGenerator);
            foreach (TFrom from in instanceGenerator.GetInstances(random, enumTestCount))
            {
                TTo   result         = advancedConverter.Convert(from);
                TFrom backwardResult = backwardAdvancedConverter.Convert(result);
                Assert.AreEqual(from, backwardResult);
            }
        }
Esempio n. 2
0
        private void NullableConverterTest <T, TFrom, TTo>(object converterObject, int count)
        {
            AdvancedConverter <TFrom, TTo> advancedConverter        = (AdvancedConverter <TFrom, TTo>)converterObject;
            AdvancedConverter <TTo, TFrom> reverseAdvancedConverter = AdvancedConverter <TTo, TFrom> .Default;
            IInstanceGenerator <T>         instanceGenerator        = InstanceGeneratorProvider.Default.GetInstanceGenerator <T>();

            foreach (T instance in instanceGenerator.GetInstances(random, count))
            {
                TTo result = advancedConverter.Convert((TFrom)(object)instance);
                if (reverseAdvancedConverter != null)
                {
                    TFrom backwardResult = reverseAdvancedConverter.Convert(result);
                    if (!advancedConverter.IsRough && !reverseAdvancedConverter.IsRough)
                    {
                        Assert.AreEqual(instance, backwardResult);
                    }
                }
            }
        }