-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSourceValueTypesTests.cs
39 lines (36 loc) · 1.48 KB
/
SourceValueTypesTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace Gu.Wpf.Validation.Tests
{
using System;
using Gu.Wpf.Validation.Internals;
using Gu.Wpf.Validation.Tests.Helpers;
using NUnit.Framework;
public class SourceValueTypesTests
{
[TestCaseSource(typeof(NumericTypesSource)), Explicit("Code gen")]
public void NullableHasProperty(Type type)
{
foreach (var source in new NumericTypesSource())
{
if (source.IsNullable())
{
var underlyingType = Nullable.GetUnderlyingType(source);
Console.WriteLine("public static readonly Type Nullable{0} = typeof({1}?);", underlyingType.Name, underlyingType.PrettyName());
}
else
{
Console.WriteLine("public static readonly Type {0} = typeof({1});", source.Name, source.PrettyName());
}
}
//if (type.IsNullable())
//{
// var field = typeof(SourceValueTypes).GetFields(BindingFlags.Static | BindingFlags.Public).SingleOrDefault(f => f.FieldType == type);
// if (field == null)
// {
// var underlyingType = Nullable.GetUnderlyingType(type);
// Console.WriteLine("public static readonly Type Nullable{0} = typeof({1}?);", underlyingType.Name, underlyingType.PrettyName());
// }
// Assert.IsTrue(field != null);
//}
}
}
}