|
1 | | -using System.Linq; |
2 | | -using Xunit; |
3 | | -using static System.Linq.Expressions.Expression; |
| 1 | +using Xunit; |
4 | 2 | using static ExpressionToString.Util.Functions; |
5 | 3 | using System.Collections.Generic; |
6 | | -using static System.Reflection.BindingFlags; |
7 | | -using System.Linq.Expressions; |
8 | 4 | using System; |
9 | 5 | using System.Reflection; |
10 | 6 | using static ExpressionToString.Tests.Categories; |
11 | 7 | using ExpressionToString.Tests.Objects; |
12 | 8 |
|
13 | 9 | namespace ExpressionToString.Tests { |
14 | | - internal class DummyMember { |
15 | | - internal string Foo { get; set; } |
16 | | - } |
17 | | - |
18 | 10 | public partial class ConstructedBase { |
19 | 11 | [Fact] |
20 | | - [Trait("Category",MemberBindings)] |
21 | | - public void MakeMemberBind() => RunTest( |
22 | | - Bind( |
23 | | - typeof(DummyMember).GetMember("Foo", Instance | NonPublic).Single(), Constant("abcd") |
24 | | - ), |
25 | | - "Foo = \"abcd\"", |
26 | | - ".Foo = \"abcd\"", |
27 | | - @"Bind( |
28 | | - typeof(DummyMember).GetProperty(""Foo""), |
29 | | - Constant(""abcd"") |
30 | | -)" |
31 | | - ); |
| 12 | + [Trait("Category", MemberBindings)] |
| 13 | + public void MakeMemberBind() => PreRunTest(); |
32 | 14 |
|
33 | 15 | [Fact] |
34 | 16 | [Trait("Category", MemberBindings)] |
35 | | - public void MakeElementInit() => RunTest( |
36 | | - ElementInit( |
37 | | - GetMethod(() => ((List<string>)null).Add("")), |
38 | | - Constant("abcd") |
39 | | - ), |
40 | | - "\"abcd\"", |
41 | | - "\"abcd\"", |
42 | | - @"ElementInit( |
43 | | - typeof(List<string>).GetMethod(""Add""), |
44 | | - Constant(""abcd"") |
45 | | -)" |
46 | | - ); |
| 17 | + public void MakeElementInit() => PreRunTest(); |
47 | 18 |
|
48 | 19 | [Fact] |
49 | 20 | [Trait("Category", MemberBindings)] |
50 | | - public void MakeElementInit2Arguments() => RunTest( |
51 | | - ElementInit( |
52 | | - GetMethod(() => ((Wrapper)null).Add("", "")), |
53 | | - Constant("abcd"), |
54 | | - Constant("efgh") |
55 | | - ), |
56 | | - @"{ |
57 | | - ""abcd"", |
58 | | - ""efgh"" |
59 | | -}", |
60 | | - @"{ |
61 | | - ""abcd"", |
62 | | - ""efgh"" |
63 | | -}", |
64 | | - @"ElementInit( |
65 | | - typeof(Wrapper).GetMethod(""Add""), |
66 | | - Constant(""abcd""), |
67 | | - Constant(""efgh"") |
68 | | -)" |
69 | | - ); |
| 21 | + public void MakeElementInit2Arguments() => PreRunTest(); |
70 | 22 |
|
71 | 23 | [Fact] |
72 | 24 | [Trait("Category", MemberBindings)] |
73 | | - public void MakeMemberMemberBind() => RunTest( |
74 | | - MemberBind( |
75 | | - GetMember(() => ((Node)null).Data), |
76 | | - Bind( |
77 | | - GetMember(() => ((NodeData)null).Name), |
78 | | - Constant("abcd") |
79 | | - ) |
80 | | - ), |
81 | | - @"Data = { |
82 | | - Name = ""abcd"" |
83 | | -}", |
84 | | - @".Data = With { |
85 | | - .Name = ""abcd"" |
86 | | -}", |
87 | | - @"MemberBind( |
88 | | - typeof(Node).GetProperty(""Data""), |
89 | | - Bind( |
90 | | - typeof(NodeData).GetProperty(""Name""), |
91 | | - Constant(""abcd"") |
92 | | - ) |
93 | | -)" |
94 | | - ); |
| 25 | + public void MakeMemberMemberBind() => PreRunTest(); |
95 | 26 |
|
96 | 27 | static readonly MethodInfo addMethod = GetMethod(() => ((IList<Node>)null).Add(new Node())); |
97 | 28 | static readonly ConstructorInfo nodeConstructor = typeof(Node).GetConstructor(new Type[] { }); |
98 | 29 |
|
99 | 30 | [Fact] |
100 | 31 | [Trait("Category", MemberBindings)] |
101 | | - public void MakeListBinding() => RunTest( |
102 | | - ListBind( |
103 | | - GetMember(() => ((Node)null).Children), |
104 | | - ElementInit(addMethod, New(nodeConstructor)), |
105 | | - ElementInit(addMethod, New(nodeConstructor)) |
106 | | - ), |
107 | | - @"Children = { |
108 | | - new Node(), |
109 | | - new Node() |
110 | | -}", |
111 | | - @".Children = From { |
112 | | - New Node, |
113 | | - New Node |
114 | | -}", |
115 | | - @"ListBind( |
116 | | - typeof(Node).GetProperty(""Children""), |
117 | | - ElementInit( |
118 | | - typeof(ICollection<Node>).GetMethod(""Add""), |
119 | | - New( |
120 | | - typeof(Node).GetConstructor() |
121 | | - ) |
122 | | - ), |
123 | | - ElementInit( |
124 | | - typeof(ICollection<Node>).GetMethod(""Add""), |
125 | | - New( |
126 | | - typeof(Node).GetConstructor() |
127 | | - ) |
128 | | - ) |
129 | | -)" |
130 | | - ); |
| 32 | + public void MakeListBinding() => PreRunTest(); |
131 | 33 | } |
132 | 34 | } |
0 commit comments