trackler 2.0.8.33 → 2.0.8.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/exercises/food-chain/Example.cs +2 -2
  4. data/tracks/csharp/exercises/food-chain/FoodChain.cs +2 -2
  5. data/tracks/csharp/exercises/food-chain/FoodChainTest.cs +150 -73
  6. data/tracks/csharp/exercises/luhn/LuhnTest.cs +5 -8
  7. data/tracks/csharp/generators/Data/CanonicalDataValue.cs +10 -0
  8. data/tracks/csharp/generators/Exercises/FoodChainExercise.cs +27 -0
  9. data/tracks/csharp/generators/Exercises/NthPrimeExercise.cs +1 -3
  10. data/tracks/csharp/generators/Methods/EqualityTestMethodGenerator.cs +25 -1
  11. data/tracks/csharp/generators/Methods/TestMethodGenerator.cs +16 -4
  12. data/tracks/csharp/generators/Methods/TestMethodOptions.cs +1 -0
  13. data/tracks/csharp/generators/Methods/TestMethodRenderer.cs +15 -7
  14. data/tracks/csharp/generators/Program.cs +2 -0
  15. data/tracks/java/exercises/difference-of-squares/src/example/java/{Difference.java → DifferenceOfSquaresCalculator.java} +4 -4
  16. data/tracks/java/exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java +5 -0
  17. data/tracks/java/exercises/difference-of-squares/src/test/java/{DifferenceTest.java → DifferenceOfSquaresCalculatorTest.java} +18 -11
  18. data/tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java +17 -9
  19. data/tracks/java/exercises/sum-of-multiples/src/test/java/SumOfMultiplesTest.java +73 -88
  20. data/tracks/perl6/.travis.yml +3 -0
  21. data/tracks/python/exercises/bob/bob_test.py +47 -71
  22. data/tracks/python/exercises/leap/leap_test.py +10 -11
  23. data/tracks/python/exercises/pangram/pangram_test.py +16 -16
  24. data/tracks/python/exercises/prime-factors/prime_factors_test.py +11 -21
  25. data/tracks/python/exercises/sieve/sieve_test.py +32 -24
  26. data/tracks/swift/.gitignore +3 -0
  27. data/tracks/swift/.swiftlint.yml +4 -2
  28. data/tracks/swift/exercises/kindergarten-garden/Sources/KindergartenGardenExample.swift +4 -4
  29. data/tracks/swift/exercises/kindergarten-garden/Tests/KindergartenGardenTests/KindergartenGardenTests.swift +25 -25
  30. data/tracks/swift/exercises/meetup/Sources/MeetupExample.swift +6 -6
  31. data/tracks/swift/exercises/poker/Sources/PokerExample.swift +12 -14
  32. data/tracks/swift/exercises/robot-simulator/Sources/RobotSimulatorExample.swift +6 -6
  33. data/tracks/swift/exercises/robot-simulator/Tests/RobotSimulatorTests/RobotSimulatorTests.swift +4 -4
  34. metadata +7 -5
  35. data/tracks/java/exercises/difference-of-squares/src/main/java/Difference.java +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 378ca12e2afc9bb24632918400f6eda2a274edbe
4
- data.tar.gz: 86c7fd6d6280d19c15a3e887f2bbd380442cec0d
3
+ metadata.gz: 467e8b1c3c1e08aa0d2a39ab3da213a0d3887255
4
+ data.tar.gz: 4ccd48c1a3f3cb53a0cc24d007f192237918ffa1
5
5
  SHA512:
6
- metadata.gz: 9e407a254474cff7f8437b2e81e94e2e961cd744e14dd4c18636b73eba4a7b067a929e4cb258b8702f3a9ffaf0037fb710bb7da052acb2d78fe5c02a15a4a7f4
7
- data.tar.gz: 837226938c97906142bb821b5917919562f475c7b0315c683a8e27b579cf7d4939fb341f188a39db94371fcb3e29adad6af0758525434f0f0017a9fd49a6230f
6
+ metadata.gz: 64dd3dca50f78d5bcd3986c94dad46d5f0e82769c06d1489295a5c3bae081178c1f77758e197937a704b5041345604df5cd3f2e8ea61dceded2f1f3f8414214e
7
+ data.tar.gz: d67de57f391f6180ddbff1fb9086ede70aa7155b51f94942d294c805af4b7bb0783a675d2c8f1cc66d82514e6e3b323d70f993f6d81565e043f8ade560dae4a2
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.8.33"
2
+ VERSION = "2.0.8.34"
3
3
  end
@@ -36,10 +36,10 @@ public static class FoodChain
36
36
  "I don't know why she swallowed the fly. Perhaps she'll die."
37
37
  };
38
38
 
39
- public static string Song() => string.Join("\n\n", Enumerable.Range(1, Verses).Select(Verse));
40
-
41
39
  public static string Verse(int number) => $"{VerseBegin(number)}\n{VerseEnd(number)}";
42
40
 
41
+ public static string Verse(int begin, int end) => string.Join("\n\n", Enumerable.Range(begin, end - begin + 1).Select(i => Verse(i)));
42
+
43
43
  private static string VerseBegin(int number)
44
44
  {
45
45
  if (number == 1)
@@ -2,12 +2,12 @@
2
2
 
3
3
  public static class FoodChain
4
4
  {
5
- public static string Song()
5
+ public static string Verse(int number)
6
6
  {
7
7
  throw new NotImplementedException("You need to implement this function.");
8
8
  }
9
9
 
10
- public static string Verse(int number)
10
+ public static string Verse(int begin, int end)
11
11
  {
12
12
  throw new NotImplementedException("You need to implement this function.");
13
13
  }
@@ -1,103 +1,180 @@
1
- using Xunit;
1
+ using Xunit;
2
2
 
3
3
  public class FoodChainTest
4
4
  {
5
5
  [Fact]
6
- public void Verse_one()
6
+ public void Fly()
7
7
  {
8
- const string expected = "I know an old lady who swallowed a fly.\n" +
9
- "I don't know why she swallowed the fly. Perhaps she'll die.";
10
-
8
+ var expected =
9
+ "I know an old lady who swallowed a fly.\n"+
10
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
11
11
  Assert.Equal(expected, FoodChain.Verse(1));
12
12
  }
13
13
 
14
14
  [Fact(Skip = "Remove to run test")]
15
- public void Verse_two()
15
+ public void Spider()
16
16
  {
17
- const string expected = "I know an old lady who swallowed a spider.\n" +
18
- "It wriggled and jiggled and tickled inside her.\n" +
19
- "She swallowed the spider to catch the fly.\n" +
20
- "I don't know why she swallowed the fly. Perhaps she'll die.";
21
-
17
+ var expected =
18
+ "I know an old lady who swallowed a spider.\n"+
19
+ "It wriggled and jiggled and tickled inside her.\n"+
20
+ "She swallowed the spider to catch the fly.\n"+
21
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
22
22
  Assert.Equal(expected, FoodChain.Verse(2));
23
23
  }
24
24
 
25
25
  [Fact(Skip = "Remove to run test")]
26
- public void Verse_four()
26
+ public void Bird()
27
27
  {
28
- const string expected = "I know an old lady who swallowed a cat.\n" +
29
- "Imagine that, to swallow a cat!\n" +
30
- "She swallowed the cat to catch the bird.\n" +
31
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
32
- "She swallowed the spider to catch the fly.\n" +
33
- "I don't know why she swallowed the fly. Perhaps she'll die.";
28
+ var expected =
29
+ "I know an old lady who swallowed a bird.\n"+
30
+ "How absurd to swallow a bird!\n"+
31
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
32
+ "She swallowed the spider to catch the fly.\n"+
33
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
34
+ Assert.Equal(expected, FoodChain.Verse(3));
35
+ }
34
36
 
37
+ [Fact(Skip = "Remove to run test")]
38
+ public void Cat()
39
+ {
40
+ var expected =
41
+ "I know an old lady who swallowed a cat.\n"+
42
+ "Imagine that, to swallow a cat!\n"+
43
+ "She swallowed the cat to catch the bird.\n"+
44
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
45
+ "She swallowed the spider to catch the fly.\n"+
46
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
35
47
  Assert.Equal(expected, FoodChain.Verse(4));
36
48
  }
37
49
 
38
50
  [Fact(Skip = "Remove to run test")]
39
- public void Verse_eight()
51
+ public void Dog()
40
52
  {
41
- const string expected = "I know an old lady who swallowed a horse.\n" +
42
- "She's dead, of course!";
53
+ var expected =
54
+ "I know an old lady who swallowed a dog.\n"+
55
+ "What a hog, to swallow a dog!\n"+
56
+ "She swallowed the dog to catch the cat.\n"+
57
+ "She swallowed the cat to catch the bird.\n"+
58
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
59
+ "She swallowed the spider to catch the fly.\n"+
60
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
61
+ Assert.Equal(expected, FoodChain.Verse(5));
62
+ }
63
+
64
+ [Fact(Skip = "Remove to run test")]
65
+ public void Goat()
66
+ {
67
+ var expected =
68
+ "I know an old lady who swallowed a goat.\n"+
69
+ "Just opened her throat and swallowed a goat!\n"+
70
+ "She swallowed the goat to catch the dog.\n"+
71
+ "She swallowed the dog to catch the cat.\n"+
72
+ "She swallowed the cat to catch the bird.\n"+
73
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
74
+ "She swallowed the spider to catch the fly.\n"+
75
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
76
+ Assert.Equal(expected, FoodChain.Verse(6));
77
+ }
43
78
 
79
+ [Fact(Skip = "Remove to run test")]
80
+ public void Cow()
81
+ {
82
+ var expected =
83
+ "I know an old lady who swallowed a cow.\n"+
84
+ "I don't know how she swallowed a cow!\n"+
85
+ "She swallowed the cow to catch the goat.\n"+
86
+ "She swallowed the goat to catch the dog.\n"+
87
+ "She swallowed the dog to catch the cat.\n"+
88
+ "She swallowed the cat to catch the bird.\n"+
89
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
90
+ "She swallowed the spider to catch the fly.\n"+
91
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
92
+ Assert.Equal(expected, FoodChain.Verse(7));
93
+ }
94
+
95
+ [Fact(Skip = "Remove to run test")]
96
+ public void Horse()
97
+ {
98
+ var expected =
99
+ "I know an old lady who swallowed a horse.\n"+
100
+ "She's dead, of course!";
44
101
  Assert.Equal(expected, FoodChain.Verse(8));
45
102
  }
46
103
 
47
104
  [Fact(Skip = "Remove to run test")]
48
- public void Complete_song()
105
+ public void Multiple_verses()
49
106
  {
50
- const string expected = "I know an old lady who swallowed a fly.\n" +
51
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
52
- "\n" +
53
- "I know an old lady who swallowed a spider.\n" +
54
- "It wriggled and jiggled and tickled inside her.\n" +
55
- "She swallowed the spider to catch the fly.\n" +
56
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
57
- "\n" +
58
- "I know an old lady who swallowed a bird.\n" +
59
- "How absurd to swallow a bird!\n" +
60
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
61
- "She swallowed the spider to catch the fly.\n" +
62
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
63
- "\n" +
64
- "I know an old lady who swallowed a cat.\n" +
65
- "Imagine that, to swallow a cat!\n" +
66
- "She swallowed the cat to catch the bird.\n" +
67
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
68
- "She swallowed the spider to catch the fly.\n" +
69
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
70
- "\n" +
71
- "I know an old lady who swallowed a dog.\n" +
72
- "What a hog, to swallow a dog!\n" +
73
- "She swallowed the dog to catch the cat.\n" +
74
- "She swallowed the cat to catch the bird.\n" +
75
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
76
- "She swallowed the spider to catch the fly.\n" +
77
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
78
- "\n" +
79
- "I know an old lady who swallowed a goat.\n" +
80
- "Just opened her throat and swallowed a goat!\n" +
81
- "She swallowed the goat to catch the dog.\n" +
82
- "She swallowed the dog to catch the cat.\n" +
83
- "She swallowed the cat to catch the bird.\n" +
84
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
85
- "She swallowed the spider to catch the fly.\n" +
86
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
87
- "\n" +
88
- "I know an old lady who swallowed a cow.\n" +
89
- "I don't know how she swallowed a cow!\n" +
90
- "She swallowed the cow to catch the goat.\n" +
91
- "She swallowed the goat to catch the dog.\n" +
92
- "She swallowed the dog to catch the cat.\n" +
93
- "She swallowed the cat to catch the bird.\n" +
94
- "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
95
- "She swallowed the spider to catch the fly.\n" +
96
- "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
97
- "\n" +
98
- "I know an old lady who swallowed a horse.\n" +
99
- "She's dead, of course!";
107
+ var expected =
108
+ "I know an old lady who swallowed a fly.\n"+
109
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
110
+ "\n"+
111
+ "I know an old lady who swallowed a spider.\n"+
112
+ "It wriggled and jiggled and tickled inside her.\n"+
113
+ "She swallowed the spider to catch the fly.\n"+
114
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
115
+ "\n"+
116
+ "I know an old lady who swallowed a bird.\n"+
117
+ "How absurd to swallow a bird!\n"+
118
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
119
+ "She swallowed the spider to catch the fly.\n"+
120
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
121
+ Assert.Equal(expected, FoodChain.Verse(1, 3));
122
+ }
100
123
 
101
- Assert.Equal(expected, FoodChain.Song());
124
+ [Fact(Skip = "Remove to run test")]
125
+ public void Full_song()
126
+ {
127
+ var expected =
128
+ "I know an old lady who swallowed a fly.\n"+
129
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
130
+ "\n"+
131
+ "I know an old lady who swallowed a spider.\n"+
132
+ "It wriggled and jiggled and tickled inside her.\n"+
133
+ "She swallowed the spider to catch the fly.\n"+
134
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
135
+ "\n"+
136
+ "I know an old lady who swallowed a bird.\n"+
137
+ "How absurd to swallow a bird!\n"+
138
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
139
+ "She swallowed the spider to catch the fly.\n"+
140
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
141
+ "\n"+
142
+ "I know an old lady who swallowed a cat.\n"+
143
+ "Imagine that, to swallow a cat!\n"+
144
+ "She swallowed the cat to catch the bird.\n"+
145
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
146
+ "She swallowed the spider to catch the fly.\n"+
147
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
148
+ "\n"+
149
+ "I know an old lady who swallowed a dog.\n"+
150
+ "What a hog, to swallow a dog!\n"+
151
+ "She swallowed the dog to catch the cat.\n"+
152
+ "She swallowed the cat to catch the bird.\n"+
153
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
154
+ "She swallowed the spider to catch the fly.\n"+
155
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
156
+ "\n"+
157
+ "I know an old lady who swallowed a goat.\n"+
158
+ "Just opened her throat and swallowed a goat!\n"+
159
+ "She swallowed the goat to catch the dog.\n"+
160
+ "She swallowed the dog to catch the cat.\n"+
161
+ "She swallowed the cat to catch the bird.\n"+
162
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
163
+ "She swallowed the spider to catch the fly.\n"+
164
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
165
+ "\n"+
166
+ "I know an old lady who swallowed a cow.\n"+
167
+ "I don't know how she swallowed a cow!\n"+
168
+ "She swallowed the cow to catch the goat.\n"+
169
+ "She swallowed the goat to catch the dog.\n"+
170
+ "She swallowed the dog to catch the cat.\n"+
171
+ "She swallowed the cat to catch the bird.\n"+
172
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"+
173
+ "She swallowed the spider to catch the fly.\n"+
174
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n"+
175
+ "\n"+
176
+ "I know an old lady who swallowed a horse.\n"+
177
+ "She's dead, of course!";
178
+ Assert.Equal(expected, FoodChain.Verse(1, 8));
102
179
  }
103
180
  }
@@ -14,32 +14,30 @@ public void A_single_zero_is_invalid()
14
14
  Assert.False(Luhn.IsValid("0"));
15
15
  }
16
16
 
17
-
18
17
  [Fact(Skip = "Remove to run test")]
19
- public void A_simple_valid_SIN_that_remains_valid_if_reversed()
18
+ public void A_simple_valid_sin_that_remains_valid_if_reversed()
20
19
  {
21
20
  Assert.True(Luhn.IsValid("059"));
22
21
  }
23
22
 
24
23
  [Fact(Skip = "Remove to run test")]
25
- public void A_simple_valid_SIN_that_becomes_invalid_if_reversed()
24
+ public void A_simple_valid_sin_that_becomes_invalid_if_reversed()
26
25
  {
27
26
  Assert.True(Luhn.IsValid("59"));
28
27
  }
29
28
 
30
29
  [Fact(Skip = "Remove to run test")]
31
- public void A_valid_Canadian_SIN()
30
+ public void A_valid_canadian_sin()
32
31
  {
33
32
  Assert.True(Luhn.IsValid("055 444 285"));
34
33
  }
35
34
 
36
35
  [Fact(Skip = "Remove to run test")]
37
- public void Invalid_Canadian_SIN()
36
+ public void Invalid_canadian_sin()
38
37
  {
39
38
  Assert.False(Luhn.IsValid("055 444 286"));
40
39
  }
41
40
 
42
-
43
41
  [Fact(Skip = "Remove to run test")]
44
42
  public void Invalid_credit_card()
45
43
  {
@@ -81,5 +79,4 @@ public void Input_digit_9_is_correctly_converted_to_output_digit_9()
81
79
  {
82
80
  Assert.True(Luhn.IsValid("091"));
83
81
  }
84
-
85
- }
82
+ }
@@ -0,0 +1,10 @@
1
+ using Newtonsoft.Json.Linq;
2
+
3
+ namespace Generators.Data
4
+ {
5
+ public static class CanonicalDataValue
6
+ {
7
+ public static string StringArrayToString(object expected)
8
+ => string.Join("\\n\"+\n\"", ((JArray) expected).Values<string>());
9
+ }
10
+ }
@@ -0,0 +1,27 @@
1
+ using Generators.Data;
2
+ using Generators.Methods;
3
+
4
+ namespace Generators.Exercises
5
+ {
6
+ public class FoodChainExercise : EqualityExercise
7
+ {
8
+ public FoodChainExercise() : base("food-chain")
9
+ {
10
+ }
11
+
12
+ protected override TestMethodData CreateTestMethodData(CanonicalData canonicalData, CanonicalDataCase canonicalDataCase, int index)
13
+ {
14
+ var testMethodData = base.CreateTestMethodData(canonicalData, canonicalDataCase, index);
15
+
16
+ testMethodData.Options.UseVariableForExpected = true;
17
+ testMethodData.CanonicalDataCase.Expected = CanonicalDataValue.StringArrayToString(canonicalDataCase.Expected);
18
+
19
+ if (testMethodData.CanonicalDataCase.Data.ContainsKey("end verse"))
20
+ testMethodData.CanonicalDataCase.Input = new[] { testMethodData.CanonicalDataCase.Data["start verse"], testMethodData.CanonicalDataCase.Data["end verse"] };
21
+ else
22
+ testMethodData.Options.InputProperty = "start verse";
23
+
24
+ return testMethodData;
25
+ }
26
+ }
27
+ }
@@ -1,7 +1,5 @@
1
1
  using System;
2
- using Generators.Data;
3
2
  using Generators.Methods;
4
- using Humanizer;
5
3
 
6
4
  namespace Generators.Exercises
7
5
  {
@@ -13,7 +11,7 @@ public NthPrimeExercise() : base("nth-prime")
13
11
 
14
12
  protected override TestMethod CreateTestMethod(TestMethodData testMethodData)
15
13
  {
16
- if (testMethodData.CanonicalDataCase.Expected is bool b)
14
+ if (testMethodData.CanonicalDataCase.Expected is bool b && !b)
17
15
  {
18
16
  testMethodData.Options.ExceptionType = typeof(ArgumentOutOfRangeException);
19
17
  return CreateExceptionTestMethod(testMethodData);
@@ -1,9 +1,12 @@
1
1
  using System;
2
+ using System.Linq;
2
3
 
3
4
  namespace Generators.Methods
4
5
  {
5
6
  public class EqualityTestMethodGenerator : TestMethodGenerator
6
7
  {
8
+ private const string Tab = " ";
9
+
7
10
  protected override string Body
8
11
  {
9
12
  get
@@ -11,15 +14,36 @@ protected override string Body
11
14
  switch (TestMethodData.Options.TestedMethodType)
12
15
  {
13
16
  case TestedMethodType.Static:
17
+ if (TestMethodData.Options.UseVariableForExpected)
18
+ return $"var expected = {FormattedExpectedVariable};\nAssert.Equal(expected, {TestedClassName}.{TestedMethod}({Input}));";
19
+
14
20
  return $"Assert.Equal({Expected}, {TestedClassName}.{TestedMethod}({Input}));";
15
21
  case TestedMethodType.Instance:
22
+ if (TestMethodData.Options.UseVariableForExpected)
23
+ return $"var expected = {FormattedExpectedVariable};\nvar sut = new {TestedClassName}();\n Assert.Equal({Expected}, sut.{TestedMethod}({Input}));";
24
+
16
25
  return $"var sut = new {TestedClassName}();\n Assert.Equal({Expected}, sut.{TestedMethod}({Input}));";
17
26
  case TestedMethodType.Extension:
27
+ if (TestMethodData.Options.UseVariableForExpected)
28
+ return $"var expected = {FormattedExpectedVariable};\nAssert.Equal(expected, {Input}.{TestedMethod}());";
29
+
18
30
  return $"Assert.Equal({Expected}, {Input}.{TestedMethod}());";
19
31
  default:
20
32
  throw new ArgumentOutOfRangeException();
21
33
  }
22
34
  }
23
- }
35
+ }
36
+
37
+ protected virtual string FormattedExpectedVariable
38
+ {
39
+ get
40
+ {
41
+ var lines = Expected.ToString().Split('\n');
42
+ if (lines.Length == 1)
43
+ return lines[0];
44
+
45
+ return "\n" + string.Join("\n", lines.Select(line => $"{Tab}{line}"));
46
+ }
47
+ }
24
48
  }
25
49
  }