@@ -47,52 +47,52 @@ public void ConvertUppercaseStringToEnum()
4747 var result = TypeConverter . ConvertStringToType ( value , typeof ( DayOfWeek ) ) ;
4848 Assert . Equal ( day , result ) ;
4949 }
50+ //TODO:
51+ //[Theory]
52+ //[InlineData(new[] { "876f5560-d0f8-4930-8089-d0d58a989928", "D5DE2533-ABCE-4870-A839-1C5E8781905F" }, typeof(Guid))]
53+ //[InlineData(new[] { "876f5560-d0f8-4930-8089-d0d58a989928", "D5DE2533-ABCE-4870-A839-1C5E8781905F" }, typeof(Guid?))]
54+ //[InlineData(new[] { "false", "true", "True", "False", "0", "1" }, typeof(bool), new[] { "false", "true", "true", "false", "false", "true" })]
55+ //[InlineData(new[] { "false", "true", "True", "False", "0", "1" }, typeof(bool?), new[] { "false", "true", "true", "false", "false", "true" })]
56+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(int))]
57+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(int?))]
58+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(short))]
59+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(short?))]
60+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(long))]
61+ //[InlineData(new[] { "0", "1", "-1", "12342" }, typeof(long?))]
62+ //[InlineData(new[] { "0", "1", "12342" }, typeof(uint))]
63+ //[InlineData(new[] { "0", "1", "12342" }, typeof(uint?))]
64+ //[InlineData(new[] { "0", "1", "12342" }, typeof(ushort))]
65+ //[InlineData(new[] { "0", "1", "12342" }, typeof(ushort?))]
66+ //[InlineData(new[] { "0", "1", "12342" }, typeof(ulong))]
67+ //[InlineData(new[] { "0", "1", "12342" }, typeof(ulong?))]
68+ //[InlineData(new[] { "2019-06-14 0:00", "1970-01-01 14:33", "2233-03-22 0:00" }, typeof(DateTime))]
69+ //[InlineData(new[] { "2019-06-14 0:00", "1970-01-01 14:33", "2233-03-22 0:00" }, typeof(DateTime?))]
70+ //[InlineData(new[] { "2019-06-14 0:00", "1970-01-01 14:33", "2233-03-22 0:00" }, typeof(DateTimeOffset))]
71+ //[InlineData(new[] { "2019-06-14 0:00", "1970-01-01 14:33", "2233-03-22 0:00" }, typeof(DateTimeOffset?))]
72+ //public void ConvertStringsToList(string[] values, Type type, string[]? expectedValues = null)
73+ //{
74+ // var results = TypeConverter.ConvertStringsToList(values, type);
75+ // var listContains = ReflectionCache.GetListContains(type)!;
76+ // Assert.Equal(values.Length, results.Count);
77+ // for (var i = 0; i < values.Length; i++)
78+ // {
79+ // string actual;
80+ // var result = results[i];
81+ // var expected = expectedValues?[i] ?? values[i];
82+ // if (result is DateTime || result is DateTimeOffset)
83+ // {
84+ // actual = $"{result:yyyy-MM-dd H:mm}";
85+ // }
86+ // else
87+ // {
88+ // actual = Convert.ToString(result)!;
89+ // }
5090
51- [ Theory ]
52- [ InlineData ( new [ ] { "876f5560-d0f8-4930-8089-d0d58a989928" , "D5DE2533-ABCE-4870-A839-1C5E8781905F" } , typeof ( Guid ) ) ]
53- [ InlineData ( new [ ] { "876f5560-d0f8-4930-8089-d0d58a989928" , "D5DE2533-ABCE-4870-A839-1C5E8781905F" } , typeof ( Guid ? ) ) ]
54- [ InlineData ( new [ ] { "false" , "true" , "True" , "False" , "0" , "1" } , typeof ( bool ) , new [ ] { "false" , "true" , "true" , "false" , "false" , "true" } ) ]
55- [ InlineData ( new [ ] { "false" , "true" , "True" , "False" , "0" , "1" } , typeof ( bool ? ) , new [ ] { "false" , "true" , "true" , "false" , "false" , "true" } ) ]
56- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( int ) ) ]
57- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( int ? ) ) ]
58- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( short ) ) ]
59- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( short ? ) ) ]
60- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( long ) ) ]
61- [ InlineData ( new [ ] { "0" , "1" , "-1" , "12342" } , typeof ( long ? ) ) ]
62- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( uint ) ) ]
63- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( uint ? ) ) ]
64- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( ushort ) ) ]
65- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( ushort ? ) ) ]
66- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( ulong ) ) ]
67- [ InlineData ( new [ ] { "0" , "1" , "12342" } , typeof ( ulong ? ) ) ]
68- [ InlineData ( new [ ] { "2019-06-14 0:00" , "1970-01-01 14:33" , "2233-03-22 0:00" } , typeof ( DateTime ) ) ]
69- [ InlineData ( new [ ] { "2019-06-14 0:00" , "1970-01-01 14:33" , "2233-03-22 0:00" } , typeof ( DateTime ? ) ) ]
70- [ InlineData ( new [ ] { "2019-06-14 0:00" , "1970-01-01 14:33" , "2233-03-22 0:00" } , typeof ( DateTimeOffset ) ) ]
71- [ InlineData ( new [ ] { "2019-06-14 0:00" , "1970-01-01 14:33" , "2233-03-22 0:00" } , typeof ( DateTimeOffset ? ) ) ]
72- public void ConvertStringsToList ( string [ ] values , Type type , string [ ] ? expectedValues = null )
73- {
74- var results = TypeConverter . ConvertStringsToList ( values , type ) ;
75- var listContains = ReflectionCache . GetListContains ( type ) ! ;
76- Assert . Equal ( values . Length , results . Count ) ;
77- for ( var i = 0 ; i < values . Length ; i ++ )
78- {
79- string actual ;
80- var result = results [ i ] ;
81- var expected = expectedValues ? [ i ] ?? values [ i ] ;
82- if ( result is DateTime || result is DateTimeOffset )
83- {
84- actual = $ "{ result : yyyy-MM-dd H:mm} ";
85- }
86- else
87- {
88- actual = Convert . ToString ( result ) ! ;
89- }
91+ // Assert.Equal(expected, actual, ignoreCase: true);
9092
91- Assert . Equal ( expected , actual , ignoreCase : true ) ;
92-
93- var convertType = type . IsGenericType ? type . GenericTypeArguments [ 0 ] : type ;
94- var contains = ( bool ) listContains . Invoke ( results , new [ ] { Convert . ChangeType ( results [ 0 ] , convertType ) } ) ! ;
95- Assert . True ( contains ) ;
96- }
97- }
93+ // var convertType = type.IsGenericType ? type.GenericTypeArguments[0] : type;
94+ // var contains = (bool)listContains.Invoke(results, new[] { Convert.ChangeType(results[0], convertType) })!;
95+ // Assert.True(contains);
96+ // }
97+ //}
9898}
0 commit comments