-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
assemblyVersioningScheme: Major |
117 changes: 117 additions & 0 deletions
117
...tanceTests/App_Packages/NSB.AcceptanceTests.5.0.0/Audit/When_a_replymessage_is_audited.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
namespace NServiceBus.AcceptanceTests.Audit | ||
{ | ||
using System; | ||
using System.Linq; | ||
using EndpointTemplates; | ||
using AcceptanceTesting; | ||
using MessageMutator; | ||
using NServiceBus.Features; | ||
using NUnit.Framework; | ||
|
||
public class When_a_replymessage_is_audited : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Should_audit_the_message() | ||
{ | ||
var context = new Context(); | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Server>() | ||
.WithEndpoint<EndpointWithAuditOn>(b => b.Given(bus => bus.Send(new Request()))) | ||
.WithEndpoint<AuditSpyEndpoint>() | ||
.Done(c => c.MessageAudited) | ||
.Run(); | ||
|
||
Assert.True(context.MessageAudited); | ||
} | ||
|
||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool MessageAudited { get; set; } | ||
} | ||
|
||
public class Server : EndpointConfigurationBuilder | ||
{ | ||
public Server() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
|
||
class RequestHandler : IHandleMessages<Request> | ||
{ | ||
public IBus Bus { get; set; } | ||
public void Handle(Request message) | ||
{ | ||
Bus.Reply(new ResponseToBeAudited()); | ||
} | ||
} | ||
} | ||
|
||
public class EndpointWithAuditOn : EndpointConfigurationBuilder | ||
{ | ||
public EndpointWithAuditOn() | ||
{ | ||
EndpointSetup<DefaultServer>(c=>c.DisableFeature<Outbox>()) | ||
.AddMapping<Request>(typeof(Server)) | ||
.AuditTo<AuditSpyEndpoint>(); | ||
} | ||
|
||
|
||
public class MessageToBeAuditedHandler : IHandleMessages<ResponseToBeAudited> | ||
{ | ||
public void Handle(ResponseToBeAudited message) | ||
{ | ||
|
||
} | ||
} | ||
} | ||
|
||
class AuditSpyEndpoint : EndpointConfigurationBuilder | ||
{ | ||
public AuditSpyEndpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
|
||
class BodySpy : IMutateIncomingTransportMessages, INeedInitialization | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public void MutateIncoming(TransportMessage transportMessage) | ||
{ | ||
Context.MessageAudited = true; | ||
} | ||
|
||
public void Customize(BusConfiguration configuration) | ||
{ | ||
configuration.RegisterComponents(c => c.ConfigureComponent<BodySpy>(DependencyLifecycle.InstancePerCall)); | ||
} | ||
} | ||
|
||
public class MessageToBeAuditedHandler : IHandleMessages<ResponseToBeAudited> | ||
{ | ||
public void Handle(ResponseToBeAudited message) | ||
{ | ||
} | ||
} | ||
} | ||
|
||
public static byte Checksum(byte[] data) | ||
{ | ||
var longSum = data.Sum(x => (long)x); | ||
return unchecked((byte)longSum); | ||
} | ||
|
||
[Serializable] | ||
public class ResponseToBeAudited : IMessage | ||
{ | ||
} | ||
|
||
|
||
class Request : IMessage | ||
{ | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Fody" version="1.24.0" targetFramework="net45" developmentDependency="true" /> | ||
<package id="GitVersionTask" version="1.2.0" targetFramework="net45" developmentDependency="true" /> | ||
<package id="GitVersionTask" version="1.3.0" targetFramework="net45" developmentDependency="true" /> | ||
<package id="Janitor.Fody" version="0.6.1.0" targetFramework="net45" /> | ||
<package id="NServiceBus" version="5.0.0" targetFramework="net45" /> | ||
<package id="NuGetPackager" version="0.1.3" targetFramework="net45" /> | ||
<package id="NuGetPackager" version="0.1.6" targetFramework="net45" /> | ||
</packages> |