Skip to content

Commit e80a701

Browse files
Fixing tests
1 parent 8c59173 commit e80a701

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

ReadableExpressions.UnitTests/Extensions/WhenGeneratingVariableNames.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,61 @@ public class WhenGeneratingVariableNames
1414
[Fact]
1515
public void ShouldNameAVariableForAnArrayType()
1616
{
17-
typeof(Box[]).GetVariableNameInCamelCase().ShouldBe("boxArray");
17+
typeof(Box[]).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("boxArray");
1818
}
1919

2020
[Fact]
2121
public void ShouldNameAVariableForACollectionTypeEndingInX()
2222
{
23-
typeof(ICollection<Box>).GetVariableNameInCamelCase().ShouldBe("boxes");
23+
typeof(ICollection<Box>).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("boxes");
2424
}
2525

2626
[Fact]
2727
public void ShouldNameAVariableForAnEnumerableTypeEndingInZ()
2828
{
29-
typeof(IEnumerable<Fuzz>).GetVariableNameInPascalCase().ShouldBe("Fuzzes");
29+
typeof(IEnumerable<Fuzz>).GetVariableNameInPascalCase(new TranslationSettings()).ShouldBe("Fuzzes");
3030
}
3131

3232
[Fact]
3333
public void ShouldNameAVariableForAnEnumerableTypeEndingInDoubleS()
3434
{
35-
typeof(IEnumerable<Glass>).GetVariableNameInPascalCase().ShouldBe("Glasses");
35+
typeof(IEnumerable<Glass>).GetVariableNameInPascalCase(new TranslationSettings()).ShouldBe("Glasses");
3636
}
3737

3838
[Fact]
3939
public void ShouldNameAVariableForAListTypeEndingInCh()
4040
{
41-
typeof(List<Church>).GetVariableNameInCamelCase().ShouldBe("churches");
41+
typeof(List<Church>).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("churches");
4242
}
4343

4444
[Fact]
4545
public void ShouldNameAVariableForAListTypeEndingInSh()
4646
{
47-
typeof(List<Hush>).GetVariableNameInCamelCase().ShouldBe("hushes");
47+
typeof(List<Hush>).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("hushes");
4848
}
4949

5050
[Fact]
5151
public void ShouldNameAVariableForAListTypeEndingInVowelY()
5252
{
53-
typeof(List<Journey>).GetVariableNameInCamelCase().ShouldBe("journeys");
53+
typeof(List<Journey>).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("journeys");
5454
}
5555

5656
[Fact]
5757
public void ShouldNameAVariableForAnIListTypeEndingInConsonantY()
5858
{
59-
typeof(IList<Body>).GetVariableNameInPascalCase().ShouldBe("Bodies");
59+
typeof(IList<Body>).GetVariableNameInPascalCase(new TranslationSettings()).ShouldBe("Bodies");
6060
}
6161

6262
[Fact]
6363
public void ShouldNameANullableLongVariable()
6464
{
65-
typeof(long?).GetVariableNameInCamelCase().ShouldBe("nullableLong");
65+
typeof(long?).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("nullableLong");
6666
}
6767

6868
[Fact]
6969
public void ShouldNameAnArrayOfArraysVariable()
7070
{
71-
typeof(int?[][]).GetVariableNameInCamelCase().ShouldBe("nullableIntArrayArray");
71+
typeof(int?[][]).GetVariableNameInCamelCase(new TranslationSettings()).ShouldBe("nullableIntArrayArray");
7272
}
7373

7474
// ReSharper disable ClassNeverInstantiated.Local

ReadableExpressions.UnitTests/Extensions/WhenGettingFriendlyNames.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ public void ShouldUseFriendlyNamesForAnonymousTypes()
4141
{
4242
var anon = new { One = 1, Two = "two" };
4343

44-
var friendlyName = anon.GetType().GetFriendlyName();
44+
var friendlyName = anon.GetType().GetFriendlyName(new TranslationSettings());
4545

4646
friendlyName.ShouldBe("AnonymousType<int, string>");
4747
}
4848

49+
[Fact]
50+
public void ShouldUseObjectForAnonymousTypesIfConfigured()
51+
{
52+
var anon = new { One = 1, Two = "two" };
53+
54+
var friendlyName = anon.GetType().GetFriendlyName(new TranslationSettings().SerializeAnonymousTypesAsObject);
55+
56+
friendlyName.ShouldBe("object");
57+
}
58+
4959
// See https://github.com/agileobjects/ReadableExpressions/issues/6
5060
[Fact]
5161
public void ShouldUseFriendlyNamesForMultiplyNestedTypes()

ReadableExpressions.UnitTests/ShouldExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ public static void ShouldBeOfType<TExpected>(this object actual)
396396
if (!(actual is TExpected))
397397
{
398398
Asplode(
399-
"An object of type " + typeof(TExpected).GetFriendlyName(),
400-
actual.GetType().GetFriendlyName());
399+
"An object of type " + typeof(TExpected).GetFriendlyName(new TranslationSettings()),
400+
actual.GetType().GetFriendlyName(new TranslationSettings()));
401401
}
402402
}
403403

ReadableExpressions/TranslationSettings.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ public class TranslationSettings
77
{
88
internal static readonly TranslationSettings Default = new TranslationSettings();
99

10-
internal TranslationSettings()
10+
/// <summary>
11+
/// Creates a Translation Settings instance.
12+
/// </summary>
13+
public TranslationSettings()
1114
{
1215
UseImplicitGenericParameters = true;
1316
}

0 commit comments

Comments
 (0)