Skip to content

Commit ad4a4af

Browse files
committed
fix for : Inconsistent policy behaviour #4
1 parent 6a51356 commit ad4a4af

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/NetArchTest.Rules/Policies/PolicyDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public PolicyResults Evaluate()
6969
var types = _typesLocator();
7070

7171
// Execute all the tests
72-
var results = _tests.Select(t => new PolicyResult(t.Definition(types).GetResult(), t.Name, t.Description));
72+
var results = _tests.Select(t => new PolicyResult(t.Definition(types).GetResult(), t.Name, t.Description)).ToList();
7373

7474
// Return the results (forcing evaluation)
75-
return new PolicyResults(results.ToList(), Name, Description);
75+
return new PolicyResults(results, Name, Description);
7676
}
7777
}
7878
}

src/NetArchTest.Rules/Types.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace NetArchTest.Rules
1616
/// </summary>
1717
public sealed class Types
1818
{
19-
private readonly RuleContext rule;
19+
private readonly IEnumerable<TypeSpec> types;
2020

2121

2222
private Types(IEnumerable<TypeSpec> types)
2323
{
24-
rule = new RuleContext(types);
24+
this.types = types;
2525
}
2626

2727

@@ -110,7 +110,7 @@ public static Types FromPath(string path, IEnumerable<string> searchDirectories
110110
/// <returns>A list of types onto which you can apply a series of filters.</returns>
111111
public Predicate That()
112112
{
113-
return new Predicate(rule);
113+
return new Predicate(new RuleContext(types));
114114
}
115115

116116
/// <summary>
@@ -119,7 +119,7 @@ public Predicate That()
119119
/// <returns></returns>
120120
public Condition Should()
121121
{
122-
return new Condition(rule, true);
122+
return new Condition(new RuleContext(types), true);
123123
}
124124

125125
/// <summary>
@@ -128,7 +128,7 @@ public Condition Should()
128128
/// <returns></returns>
129129
public Condition ShouldNot()
130130
{
131-
return new Condition(rule, false);
131+
return new Condition(new RuleContext(types), false);
132132
}
133133

134134
/// <summary>
@@ -137,7 +137,7 @@ public Condition ShouldNot()
137137
/// <returns></returns>
138138
public SlicePredicate Slice()
139139
{
140-
return new SlicePredicate(rule);
140+
return new SlicePredicate(new RuleContext(types));
141141
}
142142

143143

@@ -147,7 +147,7 @@ public SlicePredicate Slice()
147147
/// <returns>The list of <see cref="Type"/> objects in this list.</returns>
148148
public IEnumerable<IType> GetTypes()
149149
{
150-
return rule.GetTypes();
150+
return new RuleContext(types).GetTypes();
151151
}
152152
}
153153
}

0 commit comments

Comments
 (0)