-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
218f3ff
commit c6163b2
Showing
9 changed files
with
163 additions
and
30 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
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
72 changes: 72 additions & 0 deletions
72
test/ServiceAnt.IocInstaller.Autofac.Test/ServiceAntModule_Test.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,72 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Threading.Tasks; | ||
using Autofac; | ||
using ServiceAnt.Handler.Subscription.Handler; | ||
using ServiceAnt.Request.Handler; | ||
using ServiceAnt.Handler; | ||
|
||
namespace ServiceAnt.IocInstaller.Autofac.Test | ||
{ | ||
[TestClass] | ||
public class ServiceAntModule_Test | ||
{ | ||
private static string RESULT_CONTAINER = ""; | ||
|
||
public ServiceAntModule_Test() | ||
{ | ||
} | ||
|
||
[TestMethod] | ||
public async Task CanHandleEventByIocHandler() | ||
{ | ||
var testValue = "HelloWorld"; | ||
var newContainer = new ContainerBuilder(); | ||
newContainer.RegisterModule(new ServiceAntModule(System.Reflection.Assembly.GetExecutingAssembly())); | ||
var autofacContainer = newContainer.Build(); | ||
ServiceAntModule.RegisterHandlers(autofacContainer); | ||
|
||
await autofacContainer.Resolve<IServiceBus>().Publish(new TestTray() { Result = testValue }); | ||
|
||
Assert.AreEqual(testValue, RESULT_CONTAINER); | ||
} | ||
|
||
[TestMethod] | ||
public async Task CanHandleRequestByIocHandler() | ||
{ | ||
var testValue = "HelloWorld2"; | ||
var newContainer = new ContainerBuilder(); | ||
newContainer.RegisterModule(new ServiceAntModule(System.Reflection.Assembly.GetExecutingAssembly())); | ||
var autofacContainer = newContainer.Build(); | ||
ServiceAntModule.RegisterHandlers(autofacContainer); | ||
|
||
var result = await autofacContainer.Resolve<IServiceBus>().SendAsync<string>(new TestTray() { Result = testValue }); | ||
|
||
Assert.AreEqual(testValue, result); | ||
} | ||
|
||
public class TestTray : TransportTray | ||
{ | ||
public string Result { get; set; } | ||
} | ||
|
||
public class IocEventHandler : IEventHandler<TestTray> | ||
{ | ||
public Task HandleAsync(TestTray param) | ||
{ | ||
RESULT_CONTAINER = param.Result; | ||
|
||
return Task.Delay(1); | ||
} | ||
} | ||
|
||
public class IocRequestHandler : IRequestHandler<TestTray> | ||
{ | ||
public Task HandleAsync(TestTray param, IRequestHandlerContext handlerContext) | ||
{ | ||
handlerContext.Response = param.Result; | ||
return Task.Delay(1); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,5 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Autofac" version="4.6.2" targetFramework="net452" /> | ||
<package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net452" /> | ||
<package id="MSTest.TestFramework" version="1.1.18" targetFramework="net452" /> | ||
</packages> |
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