mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* [System] Fix a few hardcoded socket ports in tests Those could've shown up as "address already in use" in CI. * [System.Runtime.Remoting] Fix a few hardcoded socket ports in tests Those could've shown up as "address already in use" in CI. Additionally remove a copy of RemotingServicesTest.cs from corlib which also exists in System.Runtime.Remoting in updated form. * [System.ServiceModel] Fix a few hardcoded socket ports in tests Those could've shown up as "address already in use" in CI. * [System.Net.Http] Fix a few hardcoded socket ports in tests Those could've shown up as "address already in use" in CI. The additional "keep-alive" header in Send_Complete_NoContent() and Send_Transfer_Encoding_Chunked() is because we were using the same port for all tests before so other tests would clear the header. This doesn't happen now that we use distinct test ports. * [System.ServiceModel.Web] Fix a few hardcoded socket ports in tests Those could've shown up as "address already in use" in CI.
98 lines
2.2 KiB
C#
98 lines
2.2 KiB
C#
#if !MOBILE && !MONOMAC
|
|
|
|
using System;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Activation;
|
|
using System.ServiceModel.Channels;
|
|
using System.ServiceModel.Web;
|
|
using NUnit.Framework;
|
|
|
|
using MonoTests.Helpers;
|
|
|
|
namespace MonoTests.System.ServiceModel.Activation
|
|
{
|
|
class MyHostFactory : WebScriptServiceHostFactory
|
|
{
|
|
public ServiceHost DoCreateServiceHost (Type type, params Uri [] baseAddresses)
|
|
{
|
|
return CreateServiceHost (type, baseAddresses);
|
|
}
|
|
}
|
|
|
|
[TestFixture]
|
|
public class WebScriptServiceHostFactoryTest
|
|
{
|
|
[Test]
|
|
public void CreateServiceHost ()
|
|
{
|
|
var port = NetworkHelpers.FindFreePort ();
|
|
var f = new MyHostFactory ();
|
|
var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ($"http://localhost:{port}")});
|
|
Assert.IsFalse (host is WebServiceHost, "#1");
|
|
host.Open ();
|
|
host.Close ();
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (NotSupportedException))]
|
|
public void ResponseWrappedIsInvalid ()
|
|
{
|
|
var port = NetworkHelpers.FindFreePort ();
|
|
var f = new MyHostFactory ();
|
|
var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ($"http://localhost:{port}")});
|
|
host.Open (); // should raise an error here.
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (InvalidOperationException))]
|
|
public void MultipleContract ()
|
|
{
|
|
var port = NetworkHelpers.FindFreePort ();
|
|
var f = new MyHostFactory ();
|
|
var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ($"http://localhost:{port}")});
|
|
host.Open ();
|
|
}
|
|
|
|
}
|
|
|
|
[ServiceContract]
|
|
public interface ITestService
|
|
{
|
|
[OperationContract]
|
|
string DoWork (string s1, string s2);
|
|
}
|
|
|
|
public class TestService : ITestService
|
|
{
|
|
public string DoWork (string s1, string s2)
|
|
{
|
|
return s1 + s2;
|
|
}
|
|
}
|
|
|
|
[ServiceContract]
|
|
public interface ITestService2
|
|
{
|
|
[OperationContract]
|
|
[WebGet (BodyStyle = WebMessageBodyStyle.WrappedResponse)]
|
|
string DoWork (string s1, string s2);
|
|
}
|
|
|
|
public class TestService2 : ITestService2
|
|
{
|
|
public string DoWork (string s1, string s2)
|
|
{
|
|
return s1 + s2;
|
|
}
|
|
}
|
|
|
|
public class TestServiceMultiple : ITestService, ITestService2
|
|
{
|
|
public string DoWork (string s1, string s2)
|
|
{
|
|
return s1 + s2;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |