зеркало из https://github.com/unitycontainer/wcf.git
Add tests.
This commit is contained in:
Родитель
53581e982c
Коммит
113ad91483
|
@ -0,0 +1,23 @@
|
|||
using System.ServiceModel;
|
||||
using System.Web.Hosting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Unity.Wcf.Tests
|
||||
{
|
||||
[TestClass]
|
||||
internal class AssemblyInit
|
||||
{
|
||||
[AssemblyInitialize]
|
||||
public static void TestFixtureSetup(TestContext context)
|
||||
{
|
||||
if (!HostingEnvironment.IsHosted)
|
||||
{
|
||||
// The instance constructor hooks up the singleton hosting environment, ewww...
|
||||
new HostingEnvironment();
|
||||
|
||||
// Check the hosting environment is fully initialized
|
||||
ServiceHostingEnvironment.EnsureInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,18 +9,6 @@ namespace Unity.Wcf.Tests
|
|||
[TestClass]
|
||||
public class ServiceHostTest
|
||||
{
|
||||
[ClassInitialize]
|
||||
public static void TestFixtureSetup(TestContext context)
|
||||
{
|
||||
if (!HostingEnvironment.IsHosted)
|
||||
{
|
||||
// The instance constructor hooks up the singleton hosting environment, ewww...
|
||||
new HostingEnvironment();
|
||||
|
||||
// Check the hosting environment is fully initialized
|
||||
ServiceHostingEnvironment.EnsureInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShouldCreateServiceHost()
|
||||
|
|
|
@ -2,9 +2,6 @@ namespace Unity.Wcf.Tests.TestObjects
|
|||
{
|
||||
public class TestServiceHostFactory : UnityServiceHostFactory
|
||||
{
|
||||
protected override void ConfigureContainer(IUnityContainer container)
|
||||
{
|
||||
container.RegisterType<ITestService, TestService>();
|
||||
}
|
||||
protected override void ConfigureContainer(IUnityContainer container) => container.RegisterType<ITestService, TestService>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using Unity.Wcf.Hosting.Web;
|
||||
|
||||
namespace Unity.Wcf.Tests.TestObjects
|
||||
{
|
||||
internal class TestWebServiceHostFactory : UnityWebServiceHostFactory
|
||||
{
|
||||
protected override void ConfigureContainer(IUnityContainer container) => container.RegisterType<ITestService, TestService>();
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceModel.Activation" />
|
||||
<Reference Include="System.ServiceModel.Web" />
|
||||
<Reference Include="System.Web" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Unity.Wcf.Hosting.Web;
|
||||
using Unity.Wcf.Tests.TestObjects;
|
||||
|
||||
namespace Unity.Wcf.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class WebServiceHostTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void ShouldCreateWebServiceHost()
|
||||
{
|
||||
var fac = new TestWebServiceHostFactory();
|
||||
|
||||
var host = fac.CreateServiceHost(typeof(TestService).AssemblyQualifiedName, new Uri[0]);
|
||||
|
||||
Assert.IsInstanceOfType(host, typeof(UnityWebServiceHost));
|
||||
|
||||
Assert.AreEqual(host.Description.ServiceType, typeof(TestService));
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче