This commit is contained in:
Michael Kriese 2019-01-26 10:47:15 +01:00 коммит произвёл Michael Kriese
Родитель 53581e982c
Коммит 113ad91483
6 изменённых файлов: 57 добавлений и 16 удалений

23
tests/AssemblyInit.cs Normal file
Просмотреть файл

@ -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));
}
}
}