Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for XML Serializer #4962

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ public static string WSHttpBindingBaseAddress
get { return GetEndpointAddress("WSHttp.svc/"); }
}

public static string WSHttpRpcEncSingleNs_Address
{
get { return GetEndpointAddress("WSHttpRpcEncSingleNs.svc//Basic"); }
}

public static string WSHttpRpcEncDualNs_Address
{
get { return GetEndpointAddress("WSHttpRpcEncDualNs.svc//Basic"); }
}

public static string WSHttpRpcEncWithHeaders_Address
{
get { return GetEndpointAddress("WSHttpRpcEncWithHeaders.svc//Basic"); }
}

#region WebSocket Addresses
public static string HttpBaseAddress_NetHttpWebSockets
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,30 @@ public static void XmlSerializerFormatAttribute_SupportFaults()
[OuterLoop]
public static void XmlSerializerFormatEncodedAttributeTest()
{
BasicHttpBinding binding = null;
EndpointAddress endpointAddress = null;
// *** SETUP *** \\
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncSingleNs_Address);

XmlSerializerFormatEncodedAttributeHelper(binding, endpointAddress);
}

[WcfFact]
[OuterLoop]
public static void XmlSerializerWSHttpFormatEncodedAttributeTest()
{
// *** SETUP *** \\
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.WSHttpRpcEncSingleNs_Address);

XmlSerializerFormatEncodedAttributeHelper(binding, endpointAddress);
}

private static void XmlSerializerFormatEncodedAttributeHelper(Binding binding, EndpointAddress endpointAddress)
{
ChannelFactory<ICalculatorRpcEnc> factory1 = null;
ICalculatorRpcEnc serviceProxy1 = null;

// *** SETUP *** \\
binding = new BasicHttpBinding();
endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncSingleNs_Address);
factory1 = new ChannelFactory<ICalculatorRpcEnc>(binding, endpointAddress);
factory1.Endpoint.EndpointBehaviors.Add(new InspectorBehavior());
serviceProxy1 = factory1.CreateChannel();
Expand All @@ -159,14 +175,30 @@ public static void XmlSerializerFormatEncodedAttributeTest()
[OuterLoop]
public static void XmlSFAttributeRpcEncSingleNsTest()
{
BasicHttpBinding binding = null;
EndpointAddress endpointAddress = null;
// *** SETUP *** \\
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncSingleNs_Address);

XmlSFAttributeRpcEncSingleNsHelper(binding, endpointAddress);
}

[WcfFact]
[OuterLoop]
public static void XmlSFAttributeWSHttpRpcEncSingleNsTest()
{
// *** SETUP *** \\
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.WSHttpRpcEncSingleNs_Address);

XmlSFAttributeRpcEncSingleNsHelper(binding, endpointAddress);
}

private static void XmlSFAttributeRpcEncSingleNsHelper(Binding binding, EndpointAddress endpointAddress)
{
ChannelFactory<ICalculatorRpcEnc> factory1 = null;
ICalculatorRpcEnc serviceProxy1 = null;

// *** SETUP *** \\
binding = new BasicHttpBinding();
endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncSingleNs_Address);
factory1 = new ChannelFactory<ICalculatorRpcEnc>(binding, endpointAddress);
serviceProxy1 = factory1.CreateChannel();

Expand Down Expand Up @@ -303,21 +335,38 @@ public static void XmlSFAttributeDocLitSingleNsTest()
[OuterLoop]
public static void XmlSFAttributeRpcEncDualNsTest()
{
BasicHttpBinding binding = null;
EndpointAddress endpointAddress = null;
// *** SETUP *** \\
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncDualNs_Address);

XmlSFAttributeRpcEncDualNsHelper(binding, endpointAddress);
}

[WcfFact]
[OuterLoop]
public static void XmlSFAttributeWSHttpRpcEncDualNsTest()
{
// *** SETUP *** \\
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.WSHttpRpcEncDualNs_Address);

XmlSFAttributeRpcEncDualNsHelper(binding, endpointAddress);
}


private static void XmlSFAttributeRpcEncDualNsHelper(Binding binding, EndpointAddress endpointAddress)
{
ChannelFactory<ICalculatorRpcEnc> factory1 = null;
ChannelFactory<IHelloWorldRpcEnc> factory2 = null;
ICalculatorRpcEnc serviceProxy1 = null;
IHelloWorldRpcEnc serviceProxy2 = null;

// *** SETUP *** \\
binding = new BasicHttpBinding();
endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncDualNs_Address);
factory1 = new ChannelFactory<ICalculatorRpcEnc>(binding, endpointAddress);
serviceProxy1 = factory1.CreateChannel();
factory2 = new ChannelFactory<IHelloWorldRpcEnc>(binding, endpointAddress);
serviceProxy2 = factory2.CreateChannel();

// *** EXECUTE Variation *** \\
try
{
Expand Down Expand Up @@ -474,17 +523,33 @@ public static void XmlSFAttributeDocLitDualNsTest()
[OuterLoop]
public static void XmlSFAttributeRpcEncMessageHeaderTest()
{
BasicHttpBinding binding = null;
EndpointAddress endpointAddress = null;
// *** SETUP *** \\
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncWithHeaders_Address);

XmlSFAttributeRpcEncMessageHeaderHelper(binding, endpointAddress);
}

[WcfFact]
[OuterLoop]
public static void XmlSFAttributeWSHttpRpcEncMessageHeaderTest()
{
// *** SETUP *** \\
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Endpoints.WSHttpRpcEncWithHeaders_Address);

XmlSFAttributeRpcEncMessageHeaderHelper(binding, endpointAddress);
}

private static void XmlSFAttributeRpcEncMessageHeaderHelper(Binding binding, EndpointAddress endpointAddress)
{
ChannelFactory<IEchoRpcEncWithHeadersService> factory1 = null;
IEchoRpcEncWithHeadersService serviceProxy1 = null;
string echoText = "Hello";
string headerText = "WCF is Cool!";
string expectedHeaderText = headerText + headerText;

// *** SETUP *** \\
binding = new BasicHttpBinding();
endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncWithHeaders_Address);
factory1 = new ChannelFactory<IEchoRpcEncWithHeadersService>(binding, endpointAddress);
serviceProxy1 = factory1.CreateChannel();

Expand Down