コード例 #1
0
        public void ShouldGetPropertyByFieldNameAnonymousType()
        {
            var anType = new { Name = "one", Doub = 1.0, Int = 1 };
            PocoSerializerFactory fact = CreatePocoSerializerFactory();

            fact.Initialize(anType.GetType());

            string fields = string.Join(",", anType.GetType().GetFields(BindingFlags.Instance
                                                                        | BindingFlags.NonPublic)
                                        .Select(f => fact.GetPropertyName(f.Name)));

            Assert.That(fields, Is.EqualTo("Name,Doub,Int"));
        }
コード例 #2
0
        public string Should_Detect_All_Nullable_ColumnTypes(EFieldType fType)
        {
            var ojbType = new
            {
                Bl    = (bool?)true,
                Bt    = (byte?)3,
                Int   = (int?)33,
                Lng   = (long?)430L,
                Dbl   = (double?)34.56,
                Int16 = (Int16?)987
            };

            PocoSerializerFactory             fact = CreatePocoSerializerFactory();
            IList <IColumnSerializerMetadata> cols = fact.Initialize(ojbType.GetType()).ToList();

            return(cols.Single(c => c.ColumnType == fType).PropertyName);
        }
コード例 #3
0
        public string Should_Detect_All_Column_Types(EFieldType fType)
        {
            var ojbType = new
            {
                Bl    = true,
                Str   = "string",
                Bt    = (byte)3,
                Int   = 33,
                Lng   = 430L,
                Dbl   = 34.56,
                Int16 = (Int16)987
            };

            PocoSerializerFactory             fact = CreatePocoSerializerFactory();
            IList <IColumnSerializerMetadata> cols = fact.Initialize(ojbType.GetType()).ToList();

            return(cols.Single(c => c.ColumnType == fType).PropertyName);
        }
コード例 #4
0
        public void Should_Calculate_Nullable_Count()
        {
            var ojbType = new
            {
                Str   = "string",
                Bl    = (bool?)true,
                Bt    = (byte?)3,
                Bt2   = (byte)3,
                Int   = (int?)33,
                Lng   = (long?)430L,
                Dbl   = (double?)34.56,
                Dbl2  = 34.56,
                Int16 = (Int16?)987
            };

            PocoSerializerFactory     fact   = CreatePocoSerializerFactory();
            IColumnSerializerMetadata bitset = fact.Initialize(ojbType.GetType()).Single(c => c.ColumnType == EFieldType.BitSet);

            Assert.That(bitset.Size, Is.EqualTo(7));
        }