Skip to content

Commit 7e6f3cb

Browse files
committed
Progress in #71 -- finished test objects created with factory methods
1 parent 4964f4b commit 7e6f3cb

15 files changed

Lines changed: 454 additions & 1202 deletions
Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,26 @@
1-
using ExpressionToString.Util;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Linq.Expressions;
5-
using System.Reflection;
6-
using Xunit;
7-
using static System.Linq.Expressions.Expression;
8-
using static ExpressionToString.Tests.Globals;
1+
using Xunit;
92
using static ExpressionToString.Tests.Categories;
103

114
namespace ExpressionToString.Tests {
125
public partial class ConstructedBase {
136
[Fact]
147
[Trait("Category", Indexer)]
15-
public void MakeArrayIndex() => RunTest(
16-
ArrayIndex(arr, Constant(0)),
17-
"arr[0]",
18-
"arr(0)",
19-
@"ArrayIndex(arr,
20-
Constant(0)
21-
)"
22-
);
8+
public void MakeArrayIndex() => PreRunTest();
239

2410
[Fact]
2511
[Trait("Category", Indexer)]
26-
public void MakeArrayMultipleIndex() => RunTest(
27-
ArrayIndex(arr2D, Constant(0), Constant(1)),
28-
"arr2d[0, 1]",
29-
"arr2d(0, 1)",
30-
@"ArrayIndex(arr2d,
31-
Constant(0),
32-
Constant(1)
33-
)"
34-
);
12+
public void MakeArrayMultipleIndex() => PreRunTest();
3513

3614
[Fact]
3715
[Trait("Category", Indexer)]
38-
public void MakeArrayAccess() => RunTest(
39-
ArrayAccess(arr, Constant(0)),
40-
"arr[0]",
41-
"arr(0)",
42-
@"ArrayAccess(arr,
43-
Constant(0)
44-
)"
45-
);
16+
public void MakeArrayAccess() => PreRunTest();
4617

4718
[Fact]
4819
[Trait("Category", Indexer)]
49-
public void InstanceIndexer() => RunTest(
50-
MakeIndex(
51-
lstString, listIndexer, new[] { Constant(0) as Expression }
52-
),
53-
"lstString[0]",
54-
"lstString(0)",
55-
@"MakeIndex(lstString,
56-
typeof(List<string>).GetProperty(""Item""),
57-
new[] {
58-
Constant(0)
59-
}
60-
)"
61-
);
20+
public void InstanceIndexer() => PreRunTest();
6221

6322
[Fact]
6423
[Trait("Category", Indexer)]
65-
public void PropertyIndexer() => RunTest(
66-
Property(lstString, listIndexer, Constant(0)),
67-
"lstString[0]",
68-
"lstString(0)",
69-
@"MakeIndex(lstString,
70-
typeof(List<string>).GetProperty(""Item""),
71-
new[] {
72-
Constant(0)
73-
}
74-
)"
75-
);
24+
public void PropertyIndexer() => PreRunTest();
7625
}
7726
}

Tests.Common/Constructed/Constants.cs

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,86 +9,26 @@ namespace ExpressionToString.Tests {
99
public partial class ConstructedBase {
1010
[Fact]
1111
[Trait("Category", Constants)]
12-
public void Random() => RunTest(
13-
Constant(new Random()),
14-
"#Random",
15-
"#Random",
16-
"Constant(#Random)"
17-
);
12+
public void Random() => PreRunTest();
1813

1914
[Fact]
2015
[Trait("Category", Constants)]
21-
public void ValueTuple() => RunTest(
22-
Constant(("abcd", 5)),
23-
"(\"abcd\", 5)",
24-
"(\"abcd\", 5)",
25-
@"Constant((""abcd"", 5))"
26-
);
16+
public void ValueTuple() => PreRunTest();
2717

2818
[Fact]
2919
[Trait("Category", Constants)]
30-
public void OldTuple() => RunTest(
31-
Constant(Tuple.Create("abcd", 5)),
32-
"(\"abcd\", 5)",
33-
"(\"abcd\", 5)",
34-
@"Constant((""abcd"", 5))"
35-
);
20+
public void OldTuple() => PreRunTest();
3621

3722
[Fact]
3823
[Trait("Category", Constants)]
39-
public void DateTime() {
40-
// test rendered VB literal
41-
var dte = new DateTime(1981, 1, 1);
42-
RunTest(
43-
Constant(dte),
44-
"#DateTime",
45-
$"#{dte.ToString()}#",
46-
"Constant(#DateTime)"
47-
);
48-
}
24+
public void Array() => PreRunTest();
4925

5026
[Fact]
5127
[Trait("Category", Constants)]
52-
public void TimeSpan() {
53-
// test rendered VB literal
54-
var ts = new TimeSpan(5, 4, 3, 2);
55-
RunTest(
56-
Constant(ts),
57-
"#TimeSpan",
58-
$"#{ts.ToString()}#",
59-
"Constant(#TimeSpan)"
60-
);
61-
}
28+
public void Type() => PreRunTest();
6229

6330
[Fact]
6431
[Trait("Category", Constants)]
65-
public void Array() => RunTest(
66-
Constant(new object[] { "abcd", 5, new Random() }),
67-
"new[] { \"abcd\", 5, #Random }",
68-
"{ \"abcd\", 5, #Random }",
69-
@"Constant(new[] { ""abcd"", 5, #Random })"
70-
);
71-
72-
[Fact]
73-
[Trait("Category", Constants)]
74-
public void Type() => RunTest(
75-
Constant(typeof(string)),
76-
"typeof(string)",
77-
"GetType(String)",
78-
@"Constant(
79-
typeof(string)
80-
)"
81-
);
82-
83-
[Fact]
84-
[Trait("Category", Constants)]
85-
public void DifferentTypeForNodeAndValue() => RunTest(
86-
Constant(new List<string>(), typeof(IEnumerable)),
87-
"#List<string>",
88-
"#List(Of String)",
89-
@"Constant(#List<string>,
90-
typeof(IEnumerable)
91-
)"
92-
);
32+
public void DifferentTypeForNodeAndValue() => PreRunTest();
9333
}
9434
}

0 commit comments

Comments
 (0)