Skip to content

Commit 6c6cb1b

Browse files
committed
Made Types immutable
1 parent 5191246 commit 6c6cb1b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

TestStack.ConventionTests.Tests/CsvReportTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class CsvReportTests
1414
[Test]
1515
public void Can_run_convention_with_simple_reporter()
1616
{
17-
Convention.IsWithApprovedExeptions(new CollectionsRelationsConvention(), new Types("Entities")
18-
{
19-
TypesToVerify =
20-
typeof (Leaf).Assembly.GetExportedTypes()
21-
.Where(t => t.Namespace == typeof (Leaf).Namespace).ToArray()
22-
}, new CsvReporter());
17+
var typesToVerify = typeof (Leaf).Assembly.GetExportedTypes()
18+
.Where(t => t.Namespace == typeof (Leaf).Namespace);
19+
20+
Convention.IsWithApprovedExeptions(new CollectionsRelationsConvention(),
21+
new Types(typesToVerify, "Entities"),
22+
new CsvReporter());
2323
}
2424
}
2525
}

TestStack.ConventionTests/ConventionData/Types.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
/// </summary>
1212
public class Types : IConventionData
1313
{
14-
public Types(string descriptionOfTypes)
14+
public Types(string descriptionOfTypes) : this(Enumerable.Empty<Type>(), descriptionOfTypes)
1515
{
16+
}
17+
18+
public Types(IEnumerable<Type> types, string descriptionOfTypes)
19+
{
20+
TypesToVerify = types.ToArray();
1621
Description = descriptionOfTypes;
1722
}
1823

19-
public Type[] TypesToVerify { get; set; }
24+
public Type[] TypesToVerify { get; private set; }
2025

2126
public string Description { get; private set; }
2227

@@ -198,7 +203,7 @@ public static Types InAssemblies(IEnumerable<Assembly> assemblies, string descri
198203
/// <param name="descriptionOfTypes">A description of the matched types.</param>
199204
public static Types InCollection(IEnumerable<Type> types, string descriptionOfTypes)
200205
{
201-
return new Types(descriptionOfTypes) { TypesToVerify = types.ToArray() };
206+
return new Types(types, descriptionOfTypes);
202207
}
203208

204209
private static string GetAssemblyName(Assembly assembly)

0 commit comments

Comments
 (0)