Skip to content

Commit 3196e4a

Browse files
author
John Simons
committed
Improved the acceptance tests scanning
Fixed acceptance tests
1 parent 7e9b054 commit 3196e4a

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

src/ServiceControl.AcceptanceTests/Contexts/DefaultServer.cs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using NServiceBus.Features;
1515
using NServiceBus.Hosting.Helpers;
1616
using NServiceBus.Logging.Loggers.NLogAdapter;
17-
using ServiceControl.MessageAuditing;
1817
using TransportIntegration;
1918

2019
public class DefaultServerWithoutAudit : DefaultServer
@@ -102,20 +101,32 @@ static void SetupLogging(EndpointConfiguration endpointConfiguration)
102101

103102
static IEnumerable<Type> GetTypesToUse(EndpointConfiguration endpointConfiguration)
104103
{
105-
var assemblies = new AssemblyScanner().GetScannableAssemblies().Assemblies
106-
.Where(a => a != typeof(ProcessedMessage).Assembly).ToList();
107-
108-
109-
var types = assemblies
110-
.SelectMany(a => a.GetTypes())
111-
.Where(
112-
t =>
113-
t.Assembly != Assembly.GetExecutingAssembly() || //exclude all test types by default
114-
t.DeclaringType == endpointConfiguration.BuilderType.DeclaringType ||
115-
//but include types on the test level
116-
t.DeclaringType == endpointConfiguration.BuilderType);
117-
//and the specific types for this endpoint
118-
return types;
104+
var assemblies = new AssemblyScanner().GetScannableAssemblies();
105+
106+
var types = assemblies.Assemblies
107+
//exclude all test types by default
108+
.Where(a => a != Assembly.GetExecutingAssembly())
109+
.Where(a => a.GetName().Name != "ServiceControl")
110+
.SelectMany(a => a.GetTypes());
111+
112+
types = types.Union(GetNestedTypeRecursive(endpointConfiguration.BuilderType.DeclaringType, endpointConfiguration.BuilderType));
113+
114+
types = types.Union(endpointConfiguration.TypesToInclude);
115+
116+
return types.Where(t => !endpointConfiguration.TypesToExclude.Contains(t)).ToList();
117+
}
118+
119+
static IEnumerable<Type> GetNestedTypeRecursive(Type rootType, Type builderType)
120+
{
121+
yield return rootType;
122+
123+
if (typeof(IEndpointConfigurationFactory).IsAssignableFrom(rootType) && rootType != builderType)
124+
yield break;
125+
126+
foreach (var nestedType in rootType.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SelectMany(t => GetNestedTypeRecursive(t, builderType)))
127+
{
128+
yield return nestedType;
129+
}
119130
}
120131
}
121132
}

src/ServiceControl.AcceptanceTests/When_a_message_has_been_successfully_processed.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,15 @@ public void Start()
255255
{
256256
return;
257257
}
258+
259+
if (Configure.EndpointName != "Particular.ServiceControl")
260+
{
261+
return;
262+
}
263+
258264
var transportMessage = new TransportMessage();
259-
transportMessage.Headers["NServiceBus.MessageId"] = MyContext.MessageId;
265+
transportMessage.Headers[Headers.MessageId] = MyContext.MessageId;
266+
transportMessage.Headers[Headers.ProcessingEndpoint] = Configure.EndpointName;
260267
SendMessages.Send(transportMessage, Address.Parse("audit"));
261268
}
262269

src/ServiceControl/Infrastructure/OWIN/OwinRunner.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ public void Start()
1616

1717
public void Stop()
1818
{
19-
if (webApp == null)
20-
{
21-
return;
22-
}
23-
24-
webApp.Dispose();
25-
Logger.InfoFormat("Api is now stopped");
19+
2620
}
2721

2822
static readonly ILog Logger = LogManager.GetLogger(typeof(OwinRunner));

0 commit comments

Comments
 (0)