Skip to content

Commit bea0dfb

Browse files
scale-generator: add generator
1 parent 5f81c6f commit bea0dfb

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Xunit;
2+
3+
public class {{testClass}}
4+
{
5+
{{for test in tests}}
6+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7+
public void {{test.shortTestMethod}}()
8+
{
9+
string[] expected = {{test.expected}};
10+
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.tonic | string.literal}}{{if test.input.intervals}}, {{test.input.intervals | string.literal}}{{end}}));
11+
}
12+
{{end}}
13+
}

exercises/practice/scale-generator/ScaleGeneratorTests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,119 +5,119 @@ public class ScaleGeneratorTests
55
[Fact]
66
public void Chromatic_scale_with_sharps()
77
{
8-
var expected = new[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
8+
string[] expected = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
99
Assert.Equal(expected, ScaleGenerator.Chromatic("C"));
1010
}
1111

1212
[Fact(Skip = "Remove this Skip property to run this test")]
1313
public void Chromatic_scale_with_flats()
1414
{
15-
var expected = new[] { "F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E" };
15+
string[] expected = ["F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E"];
1616
Assert.Equal(expected, ScaleGenerator.Chromatic("F"));
1717
}
1818

1919
[Fact(Skip = "Remove this Skip property to run this test")]
2020
public void Simple_major_scale()
2121
{
22-
var expected = new[] { "C", "D", "E", "F", "G", "A", "B", "C" };
22+
string[] expected = ["C", "D", "E", "F", "G", "A", "B", "C"];
2323
Assert.Equal(expected, ScaleGenerator.Interval("C", "MMmMMMm"));
2424
}
2525

2626
[Fact(Skip = "Remove this Skip property to run this test")]
2727
public void Major_scale_with_sharps()
2828
{
29-
var expected = new[] { "G", "A", "B", "C", "D", "E", "F#", "G" };
29+
string[] expected = ["G", "A", "B", "C", "D", "E", "F#", "G"];
3030
Assert.Equal(expected, ScaleGenerator.Interval("G", "MMmMMMm"));
3131
}
3232

3333
[Fact(Skip = "Remove this Skip property to run this test")]
3434
public void Major_scale_with_flats()
3535
{
36-
var expected = new[] { "F", "G", "A", "Bb", "C", "D", "E", "F" };
36+
string[] expected = ["F", "G", "A", "Bb", "C", "D", "E", "F"];
3737
Assert.Equal(expected, ScaleGenerator.Interval("F", "MMmMMMm"));
3838
}
3939

4040
[Fact(Skip = "Remove this Skip property to run this test")]
4141
public void Minor_scale_with_sharps()
4242
{
43-
var expected = new[] { "F#", "G#", "A", "B", "C#", "D", "E", "F#" };
43+
string[] expected = ["F#", "G#", "A", "B", "C#", "D", "E", "F#"];
4444
Assert.Equal(expected, ScaleGenerator.Interval("f#", "MmMMmMM"));
4545
}
4646

4747
[Fact(Skip = "Remove this Skip property to run this test")]
4848
public void Minor_scale_with_flats()
4949
{
50-
var expected = new[] { "Bb", "C", "Db", "Eb", "F", "Gb", "Ab", "Bb" };
50+
string[] expected = ["Bb", "C", "Db", "Eb", "F", "Gb", "Ab", "Bb"];
5151
Assert.Equal(expected, ScaleGenerator.Interval("bb", "MmMMmMM"));
5252
}
5353

5454
[Fact(Skip = "Remove this Skip property to run this test")]
5555
public void Dorian_mode()
5656
{
57-
var expected = new[] { "D", "E", "F", "G", "A", "B", "C", "D" };
57+
string[] expected = ["D", "E", "F", "G", "A", "B", "C", "D"];
5858
Assert.Equal(expected, ScaleGenerator.Interval("d", "MmMMMmM"));
5959
}
6060

6161
[Fact(Skip = "Remove this Skip property to run this test")]
6262
public void Mixolydian_mode()
6363
{
64-
var expected = new[] { "Eb", "F", "G", "Ab", "Bb", "C", "Db", "Eb" };
64+
string[] expected = ["Eb", "F", "G", "Ab", "Bb", "C", "Db", "Eb"];
6565
Assert.Equal(expected, ScaleGenerator.Interval("Eb", "MMmMMmM"));
6666
}
6767

6868
[Fact(Skip = "Remove this Skip property to run this test")]
6969
public void Lydian_mode()
7070
{
71-
var expected = new[] { "A", "B", "C#", "D#", "E", "F#", "G#", "A" };
71+
string[] expected = ["A", "B", "C#", "D#", "E", "F#", "G#", "A"];
7272
Assert.Equal(expected, ScaleGenerator.Interval("a", "MMMmMMm"));
7373
}
7474

7575
[Fact(Skip = "Remove this Skip property to run this test")]
7676
public void Phrygian_mode()
7777
{
78-
var expected = new[] { "E", "F", "G", "A", "B", "C", "D", "E" };
78+
string[] expected = ["E", "F", "G", "A", "B", "C", "D", "E"];
7979
Assert.Equal(expected, ScaleGenerator.Interval("e", "mMMMmMM"));
8080
}
8181

8282
[Fact(Skip = "Remove this Skip property to run this test")]
8383
public void Locrian_mode()
8484
{
85-
var expected = new[] { "G", "Ab", "Bb", "C", "Db", "Eb", "F", "G" };
85+
string[] expected = ["G", "Ab", "Bb", "C", "Db", "Eb", "F", "G"];
8686
Assert.Equal(expected, ScaleGenerator.Interval("g", "mMMmMMM"));
8787
}
8888

8989
[Fact(Skip = "Remove this Skip property to run this test")]
9090
public void Harmonic_minor()
9191
{
92-
var expected = new[] { "D", "E", "F", "G", "A", "Bb", "Db", "D" };
92+
string[] expected = ["D", "E", "F", "G", "A", "Bb", "Db", "D"];
9393
Assert.Equal(expected, ScaleGenerator.Interval("d", "MmMMmAm"));
9494
}
9595

9696
[Fact(Skip = "Remove this Skip property to run this test")]
9797
public void Octatonic()
9898
{
99-
var expected = new[] { "C", "D", "D#", "F", "F#", "G#", "A", "B", "C" };
99+
string[] expected = ["C", "D", "D#", "F", "F#", "G#", "A", "B", "C"];
100100
Assert.Equal(expected, ScaleGenerator.Interval("C", "MmMmMmMm"));
101101
}
102102

103103
[Fact(Skip = "Remove this Skip property to run this test")]
104104
public void Hexatonic()
105105
{
106-
var expected = new[] { "Db", "Eb", "F", "G", "A", "B", "Db" };
106+
string[] expected = ["Db", "Eb", "F", "G", "A", "B", "Db"];
107107
Assert.Equal(expected, ScaleGenerator.Interval("Db", "MMMMMM"));
108108
}
109109

110110
[Fact(Skip = "Remove this Skip property to run this test")]
111111
public void Pentatonic()
112112
{
113-
var expected = new[] { "A", "B", "C#", "E", "F#", "A" };
113+
string[] expected = ["A", "B", "C#", "E", "F#", "A"];
114114
Assert.Equal(expected, ScaleGenerator.Interval("A", "MMAMA"));
115115
}
116116

117117
[Fact(Skip = "Remove this Skip property to run this test")]
118118
public void Enigmatic()
119119
{
120-
var expected = new[] { "G", "G#", "B", "C#", "D#", "F", "F#", "G" };
120+
string[] expected = ["G", "G#", "B", "C#", "D#", "F", "F#", "G"];
121121
Assert.Equal(expected, ScaleGenerator.Interval("G", "mAMMMmm"));
122122
}
123123
}

0 commit comments

Comments
 (0)