@@ -30,31 +30,35 @@ public class WsdlTests
30
30
31
31
private IWebHost _host ;
32
32
33
- [ TestMethod ]
34
- public async Task CheckBindingAndPortName ( )
33
+ [ DataTestMethod ]
34
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
35
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
36
+ public async Task CheckBindingAndPortName ( SoapSerializer soapSerializer )
35
37
{
36
- var wsdl = await GetWsdlFromMetaBodyWriter < TaskNoReturnService > ( SoapSerializer . XmlSerializer , "MyBinding " , "MyPort " ) ;
38
+ var wsdl = await GetWsdlFromMetaBodyWriter < TaskNoReturnService > ( soapSerializer , "BindingName " , "PortName " ) ;
37
39
var root = XElement . Parse ( wsdl ) ;
38
40
39
41
// We should have in the wsdl the definition of a complex type representing the nullable enum
40
- var bindingElements = GetElements ( root , _wsdlSchema + "binding" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "MyBinding " ) == true ) . ToArray ( ) ;
42
+ var bindingElements = GetElements ( root , _wsdlSchema + "binding" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "BindingName " ) == true ) . ToArray ( ) ;
41
43
bindingElements . ShouldNotBeEmpty ( ) ;
42
44
43
- var portElements = GetElements ( root , _wsdlSchema + "port" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "MyPort " ) == true ) . ToArray ( ) ;
45
+ var portElements = GetElements ( root , _wsdlSchema + "port" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "PortName " ) == true ) . ToArray ( ) ;
44
46
portElements . ShouldNotBeEmpty ( ) ;
45
47
}
46
48
47
- [ TestMethod ]
48
- public async Task CheckDefaultBindingAndPortName ( )
49
+ [ DataTestMethod ]
50
+ [ DataRow ( SoapSerializer . XmlSerializer , "_soap" ) ]
51
+ [ DataRow ( SoapSerializer . DataContractSerializer , "" ) ]
52
+ public async Task CheckDefaultBindingAndPortName ( SoapSerializer soapSerializer , string bindingSuffix )
49
53
{
50
- var wsdl = await GetWsdlFromMetaBodyWriter < TaskNoReturnService > ( SoapSerializer . XmlSerializer ) ;
54
+ var wsdl = await GetWsdlFromMetaBodyWriter < TaskNoReturnService > ( soapSerializer ) ;
51
55
var root = XElement . Parse ( wsdl ) ;
52
56
53
57
// We should have in the wsdl the definition of a complex type representing the nullable enum
54
- var bindingElements = GetElements ( root , _wsdlSchema + "binding" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "BasicHttpBinding_soap" ) == true ) . ToArray ( ) ;
58
+ var bindingElements = GetElements ( root , _wsdlSchema + "binding" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "BasicHttpBinding" + bindingSuffix ) == true ) . ToArray ( ) ;
55
59
bindingElements . ShouldNotBeEmpty ( ) ;
56
60
57
- var portElements = GetElements ( root , _wsdlSchema + "port" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "BasicHttpBinding_soap" ) == true ) . ToArray ( ) ;
61
+ var portElements = GetElements ( root , _wsdlSchema + "port" ) . Where ( a => a . Attribute ( "name" ) ? . Value . Equals ( "BasicHttpBinding" + bindingSuffix ) == true ) . ToArray ( ) ;
58
62
portElements . ShouldNotBeEmpty ( ) ;
59
63
}
60
64
@@ -440,13 +444,15 @@ public void CheckDictionaryTypeDataContract()
440
444
Assert . IsNotNull ( myStringElement ) ;
441
445
}
442
446
443
- [ TestMethod ]
444
- public async Task CheckStringArrayNameWsdl ( )
447
+ [ DataTestMethod ]
448
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
449
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
450
+ public async Task CheckStringArrayNameWsdl ( SoapSerializer soapSerializer )
445
451
{
446
452
//StartService(typeof(StringListService));
447
453
//var wsdl = GetWsdl();
448
454
//StopServer();
449
- var wsdl = await GetWsdlFromMetaBodyWriter < StringListService > ( SoapSerializer . XmlSerializer ) ;
455
+ var wsdl = await GetWsdlFromMetaBodyWriter < StringListService > ( soapSerializer ) ;
450
456
Trace . TraceInformation ( wsdl ) ;
451
457
Assert . IsNotNull ( wsdl ) ;
452
458
@@ -476,13 +482,15 @@ public async Task CheckStringArrayNameWsdl()
476
482
Assert . IsTrue ( matched ) ;
477
483
}
478
484
479
- [ TestMethod ]
480
- public async Task CheckComplexTypeAndOutParameterWsdl ( )
485
+ [ DataTestMethod ]
486
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
487
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
488
+ public async Task CheckComplexTypeAndOutParameterWsdl ( SoapSerializer soapSerializer )
481
489
{
482
490
//StartService(typeof(StringListService));
483
491
//var wsdl = GetWsdl();
484
492
//StopServer();
485
- var wsdl = await GetWsdlFromMetaBodyWriter < ComplexTypeAndOutParameterService > ( SoapSerializer . XmlSerializer ) ;
493
+ var wsdl = await GetWsdlFromMetaBodyWriter < ComplexTypeAndOutParameterService > ( soapSerializer ) ;
486
494
Trace . TraceInformation ( wsdl ) ;
487
495
Assert . IsNotNull ( wsdl ) ;
488
496
@@ -507,10 +515,12 @@ public async Task CheckComplexTypeAndOutParameterWsdl()
507
515
Assert . IsNotNull ( testElementMessage ) ;
508
516
}
509
517
510
- [ TestMethod ]
511
- public async Task CheckUnqualifiedMembersService ( )
518
+ [ DataTestMethod ]
519
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
520
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
521
+ public async Task CheckUnqualifiedMembersService ( SoapSerializer soapSerializer )
512
522
{
513
- var wsdl = await GetWsdlFromMetaBodyWriter < UnqualifiedMembersService > ( SoapSerializer . XmlSerializer ) ;
523
+ var wsdl = await GetWsdlFromMetaBodyWriter < TaskNoReturnService > ( soapSerializer , "BindingName" , "PortName" ) ;
514
524
Trace . TraceInformation ( wsdl ) ;
515
525
516
526
var root = XElement . Parse ( wsdl ) ;
@@ -525,13 +535,15 @@ public async Task CheckUnqualifiedMembersService()
525
535
Assert . IsTrue ( allNeededAreQualified ) ;
526
536
}
527
537
528
- [ TestMethod ]
529
- public async Task CheckDateTimeOffsetServiceWsdl ( )
538
+ [ DataTestMethod ]
539
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
540
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
541
+ public async Task CheckDateTimeOffsetServiceWsdl ( SoapSerializer soapSerializer )
530
542
{
531
543
var nm = Namespaces . CreateDefaultXmlNamespaceManager ( ) ;
532
544
string systemNs = "http://schemas.datacontract.org/2004/07/System" ;
533
545
534
- var wsdl = await GetWsdlFromMetaBodyWriter < DateTimeOffsetService > ( SoapSerializer . XmlSerializer ) ;
546
+ var wsdl = await GetWsdlFromMetaBodyWriter < DateTimeOffsetService > ( soapSerializer ) ;
535
547
var root = XElement . Parse ( wsdl ) ;
536
548
var responseDateElem = root . XPathSelectElement ( $ "//xsd:element[@name='MethodResponse']/xsd:complexType/xsd:sequence/xsd:element[@name='MethodResult']", nm ) ;
537
549
Assert . IsTrue ( responseDateElem . ToString ( ) . Contains ( systemNs ) ) ;
@@ -544,10 +556,12 @@ public async Task CheckDateTimeOffsetServiceWsdl()
544
556
Assert . IsNull ( dayOfYearElem ) ;
545
557
}
546
558
547
- [ TestMethod ]
548
- public async Task CheckXmlSchemaProviderTypeServiceWsdl ( )
559
+ [ DataTestMethod ]
560
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
561
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
562
+ public async Task CheckXmlSchemaProviderTypeServiceWsdl ( SoapSerializer soapSerializer )
549
563
{
550
- var wsdl = await GetWsdlFromMetaBodyWriter < XmlSchemaProviderTypeService > ( SoapSerializer . XmlSerializer ) ;
564
+ var wsdl = await GetWsdlFromMetaBodyWriter < XmlSchemaProviderTypeService > ( soapSerializer ) ;
551
565
Trace . TraceInformation ( wsdl ) ;
552
566
Assert . IsNotNull ( wsdl ) ;
553
567
@@ -558,10 +572,12 @@ public async Task CheckXmlSchemaProviderTypeServiceWsdl()
558
572
Assert . IsNotNull ( responseDateElem ) ;
559
573
}
560
574
561
- [ TestMethod ]
562
- public async Task CheckTestMultipleTypesServiceWsdl ( )
575
+ [ DataTestMethod ]
576
+ [ DataRow ( SoapSerializer . XmlSerializer ) ]
577
+ [ DataRow ( SoapSerializer . DataContractSerializer ) ]
578
+ public async Task CheckTestMultipleTypesServiceWsdl ( SoapSerializer soapSerializer )
563
579
{
564
- var wsdl = await GetWsdlFromMetaBodyWriter < TestMultipleTypesService > ( SoapSerializer . XmlSerializer ) ;
580
+ var wsdl = await GetWsdlFromMetaBodyWriter < TestMultipleTypesService > ( soapSerializer ) ;
565
581
Trace . TraceInformation ( wsdl ) ;
566
582
Assert . IsNotNull ( wsdl ) ;
567
583
}
@@ -639,7 +655,7 @@ public void CheckFieldMembersASMX()
639
655
Assert . AreEqual ( 5 , propElementsCount ) ;
640
656
}
641
657
642
- [ TestMethod ]
658
+ [ DataTestMethod ]
643
659
public async Task CheckXmlAnnotatedTypeServiceWsdl ( )
644
660
{
645
661
var wsdl = await GetWsdlFromMetaBodyWriter < XmlModelsService > ( SoapSerializer . XmlSerializer ) ;
@@ -685,7 +701,7 @@ public async Task CheckXmlAnnotatedTypeServiceWsdl()
685
701
Assert . IsNotNull ( propAnonAttribute ) ;
686
702
}
687
703
688
- [ TestMethod ]
704
+ [ DataTestMethod ]
689
705
public async Task CheckXmlAnnotatedChoiceReturnServiceWsdl ( )
690
706
{
691
707
var wsdl = await GetWsdlFromMetaBodyWriter < XmlAnnotatedChoiceReturnService > ( SoapSerializer . XmlSerializer ) ;
@@ -716,7 +732,7 @@ public async Task CheckXmlAnnotatedChoiceReturnServiceWsdl()
716
732
Assert . IsNotNull ( choiceComplexTypeElement . XPathSelectElement ( "//xsd:complexType/xsd:sequence/xsd:choice/xsd:element[@name='second' and @type='xsd:string']" , nm ) ) ;
717
733
}
718
734
719
- [ TestMethod ]
735
+ [ DataTestMethod ]
720
736
public async Task CheckMessageHeadersServiceWsdl ( )
721
737
{
722
738
var wsdl = await GetWsdlFromMetaBodyWriter < MessageHeadersService > ( SoapSerializer . XmlSerializer ) ;
@@ -774,12 +790,13 @@ private async Task<string> GetWsdlFromMetaBodyWriter<T>(SoapSerializer serialize
774
790
var service = new ServiceDescription ( typeof ( T ) ) ;
775
791
var baseUrl = "http://tempuri.org/" ;
776
792
var xmlNamespaceManager = Namespaces . CreateDefaultXmlNamespaceManager ( ) ;
793
+ var defaultBindingName = ! string . IsNullOrWhiteSpace ( bindingName ) ? bindingName : "BasicHttpBinding" ;
777
794
var bodyWriter = serializer == SoapSerializer . DataContractSerializer
778
- ? new MetaWCFBodyWriter ( service , baseUrl , "BasicHttpBinding" , false ) as BodyWriter
779
- : new MetaBodyWriter ( service , baseUrl , xmlNamespaceManager , "BasicHttpBinding" , new [ ] { new SoapBindingInfo ( MessageVersion . None , bindingName , portName ) } ) as BodyWriter ;
795
+ ? new MetaWCFBodyWriter ( service , baseUrl , defaultBindingName , false , new [ ] { new SoapBindingInfo ( MessageVersion . None , bindingName , portName ) } ) as BodyWriter
796
+ : new MetaBodyWriter ( service , baseUrl , xmlNamespaceManager , defaultBindingName , new [ ] { new SoapBindingInfo ( MessageVersion . None , bindingName , portName ) } ) as BodyWriter ;
780
797
var encoder = new SoapMessageEncoder ( MessageVersion . Soap12WSAddressingAugust2004 , System . Text . Encoding . UTF8 , XmlDictionaryReaderQuotas . Max , false , true , false , null , bindingName , portName ) ;
781
798
var responseMessage = Message . CreateMessage ( encoder . MessageVersion , null , bodyWriter ) ;
782
- responseMessage = new MetaMessage ( responseMessage , service , xmlNamespaceManager , "BasicHttpBinding" , false ) ;
799
+ responseMessage = new MetaMessage ( responseMessage , service , xmlNamespaceManager , defaultBindingName , false ) ;
783
800
784
801
using ( var memoryStream = new MemoryStream ( ) )
785
802
{
0 commit comments