Skip to content

Commit 4964f4b

Browse files
committed
Progress on #71 -- Factory methods Goto, MemberBinding, Methods, New object
1 parent 25e9648 commit 4964f4b

8 files changed

Lines changed: 251 additions & 513 deletions

File tree

Tests.Common/Constructed/MakeGoto.cs

Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,85 +5,32 @@
55

66
namespace ExpressionToString.Tests {
77
public partial class ConstructedBase {
8-
private LabelTarget labelTarget = Label("target");
9-
108
[Fact]
11-
[Trait("Category",Gotos)]
12-
public void MakeBreak() => RunTest(
13-
Break(labelTarget),
14-
"break target",
15-
"Exit target",
16-
@"Break(
17-
Label(""target"")
18-
)"
19-
);
9+
[Trait("Category", Gotos)]
10+
public void MakeBreak() => PreRunTest();
2011

2112
[Fact]
2213
[Trait("Category", Gotos)]
23-
public void MakeBreakWithValue() => RunTest(
24-
Break(labelTarget, Constant(5)),
25-
"break target 5",
26-
"Exit target 5", @"Break(
27-
Label(""target""),
28-
Constant(5)
29-
)"
30-
);
14+
public void MakeBreakWithValue() => PreRunTest();
3115

3216
[Fact]
3317
[Trait("Category", Gotos)]
34-
public void MakeContinue() => RunTest(
35-
Continue(labelTarget),
36-
"continue target",
37-
"Continue target",
38-
@"Continue(
39-
Label(""target"")
40-
)"
41-
);
18+
public void MakeContinue() => PreRunTest();
4219

4320
[Fact]
4421
[Trait("Category", Gotos)]
45-
public void MakeGotoWithoutValue() => RunTest(
46-
Goto(labelTarget),
47-
"goto target",
48-
"Goto target",
49-
@"Goto(
50-
Label(""target"")
51-
)"
52-
);
22+
public void MakeGotoWithoutValue() => PreRunTest();
5323

5424
[Fact]
5525
[Trait("Category", Gotos)]
56-
public void MakeGotoWithValue() => RunTest(
57-
Goto(labelTarget, Constant(5)),
58-
"goto target 5",
59-
"Goto target 5",
60-
@"Goto(
61-
Label(""target""),
62-
Constant(5)
63-
)"
64-
);
26+
public void MakeGotoWithValue() => PreRunTest();
6527

6628
[Fact]
6729
[Trait("Category", Gotos)]
68-
public void MakeReturn() => RunTest(
69-
Return(labelTarget),
70-
"return target",
71-
"Return target",
72-
@"Return(
73-
Label(""target"")
74-
)"
75-
);
30+
public void MakeReturn() => PreRunTest();
7631

7732
[Fact]
7833
[Trait("Category", Gotos)]
79-
public void MakeReturnWithValue() => RunTest(
80-
Return(labelTarget, Constant(5)),
81-
"return target 5",
82-
"Return target 5",
83-
@"Return(
84-
Label(""target""),
85-
Constant(5)
86-
)"
87-
);
34+
public void MakeReturnWithValue() => PreRunTest();
8835
}
8936
}
Lines changed: 7 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,34 @@
1-
using System.Linq;
2-
using Xunit;
3-
using static System.Linq.Expressions.Expression;
1+
using Xunit;
42
using static ExpressionToString.Util.Functions;
53
using System.Collections.Generic;
6-
using static System.Reflection.BindingFlags;
7-
using System.Linq.Expressions;
84
using System;
95
using System.Reflection;
106
using static ExpressionToString.Tests.Categories;
117
using ExpressionToString.Tests.Objects;
128

139
namespace ExpressionToString.Tests {
14-
internal class DummyMember {
15-
internal string Foo { get; set; }
16-
}
17-
1810
public partial class ConstructedBase {
1911
[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();
3214

3315
[Fact]
3416
[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();
4718

4819
[Fact]
4920
[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();
7022

7123
[Fact]
7224
[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();
9526

9627
static readonly MethodInfo addMethod = GetMethod(() => ((IList<Node>)null).Add(new Node()));
9728
static readonly ConstructorInfo nodeConstructor = typeof(Node).GetConstructor(new Type[] { });
9829

9930
[Fact]
10031
[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();
13133
}
13234
}

0 commit comments

Comments
 (0)