-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1044 from Yozer/feat-custom-wsdl-param-names
feat(wsdl-meta): allow to customize message names for operation
- Loading branch information
Showing
7 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/SoapCore.Tests/Wsdl/DefaultWsdlOperationNameGeneratorTests.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,40 @@ | ||
using System.ServiceModel; | ||
using SoapCore.Meta; | ||
using SoapCore.ServiceModel; | ||
using SoapCore.Tests.Wsdl.Services; | ||
using Xunit; | ||
|
||
namespace SoapCore.Tests.Wsdl | ||
{ | ||
public class DefaultWsdlOperationNameGeneratorTests | ||
{ | ||
private readonly ServiceDescription _serviceDescription; | ||
private readonly ServiceModel.OperationDescription _operation; | ||
private readonly DefaultWsdlOperationNameGenerator _generator; | ||
|
||
public DefaultWsdlOperationNameGeneratorTests() | ||
{ | ||
_serviceDescription = new ServiceDescription(typeof(IEnumService), false); | ||
var contractDescription = new ContractDescription(_serviceDescription, typeof(IEnumService), new ServiceContractAttribute(), false); | ||
var method = typeof(IEnumService).GetMethod(nameof(IEnumService.Method)); | ||
var contractAttribute = new OperationContractAttribute(); | ||
_operation = new ServiceModel.OperationDescription(contractDescription, method, contractAttribute, false); | ||
|
||
_generator = new DefaultWsdlOperationNameGenerator(); | ||
} | ||
|
||
[Fact] | ||
public void TestGenerateWsdlInputMessageName() | ||
{ | ||
var result = _generator.GenerateWsdlInputMessageName(_operation, _serviceDescription); | ||
Assert.Equal("IEnumService_Method_InputMessage", result); | ||
} | ||
|
||
[Fact] | ||
public void TestGenerateWsdlOutputMessageName() | ||
{ | ||
var result = _generator.GenerateWsdlOutputMessageName(_operation, _serviceDescription); | ||
Assert.Equal("IEnumService_Method_OutputMessage", result); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using SoapCore.ServiceModel; | ||
|
||
namespace SoapCore.Meta | ||
{ | ||
public interface IWsdlOperationNameGenerator | ||
{ | ||
string GenerateWsdlInputMessageName(OperationDescription operation, ServiceDescription service); | ||
string GenerateWsdlOutputMessageName(OperationDescription operation, ServiceDescription service); | ||
} | ||
|
||
public class DefaultWsdlOperationNameGenerator : IWsdlOperationNameGenerator | ||
{ | ||
public string GenerateWsdlInputMessageName(OperationDescription operation, ServiceDescription service) | ||
{ | ||
return $"{service.GeneralContract.Name}_{operation.Name}_InputMessage"; | ||
} | ||
|
||
public string GenerateWsdlOutputMessageName(OperationDescription operation, ServiceDescription service) | ||
{ | ||
return $"{service.GeneralContract.Name}_{operation.Name}_OutputMessage"; | ||
} | ||
} | ||
} |
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