Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,58 @@
//
// AddressHeaderCollectionElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class AddressHeaderCollectionElementTest
{
[Test]
public void ReadConfiguration () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/client.endpoint").GetSectionGroup ("system.serviceModel");
AddressHeaderCollection col = config.Client.Endpoints [0].Headers.Headers;
Assert.AreEqual (2, col.Count, "count");
AddressHeader header = col [0];
Assert.AreEqual ("Header1", header.Name, "name");
Assert.AreEqual ("", header.Namespace, "name");
header = col [1];
Assert.AreEqual ("Header2", header.Name, "name");
Assert.AreEqual ("uri:my.custom.manespace", header.Namespace, "name");
}
}
}

View File

@ -0,0 +1,65 @@
//
// BasicHttpBindingElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class BasicHttpBindingElementTest
{
class Poker : BasicHttpBindingElement
{
public Type GetBindingElementType () {
return BindingElementType;
}
}
[Test]
public void BindingElementType () {
Poker poker = new Poker ();
Assert.AreEqual (typeof (BasicHttpBinding), poker.GetBindingElementType (), "BindingElementType");
}
[Test]
public void DefaultTextEncoding ()
{
var b1 = new BasicHttpBinding ();
var b2 = new BasicHttpBinding ();
Assert.AreEqual (b1.TextEncoding, b2.TextEncoding, "#1");
var element = new BasicHttpBindingElement ();
Assert.AreEqual (element.TextEncoding, b1.TextEncoding, "#2");
}
}
}

View File

@ -0,0 +1,64 @@
//
// BehaviorsSectionTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class BehaviorsSectionTest
{
class Poker : BehaviorsSection
{
public ConfigurationPropertyCollection GetProperties () {
return Properties;
}
[ConfigurationProperty ("myProperty")]
string MyProperty {
get { return "myProperty"; }
set { }
}
}
[Test]
public void Properties () {
Poker p1 = new Poker ();
Poker p2 = new Poker ();
Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
}
}
}

View File

@ -0,0 +1,62 @@
//
// BindingsSectionTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class BindingsSectionTest
{
[Test]
[Category("NotWorking")]
[Ignore ("fails under .NET; I never bothered to fix the test")]
public void UserConfiguration () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/userBinding").GetSectionGroup ("system.serviceModel");
BindingsSection section = config.Bindings;
BindingCollectionElement collectionElement = section ["userBinding"];
Assert.AreEqual (typeof (UserBindingCollectionElement), collectionElement.GetType (), "type");
StandardBindingElementCollection<UserBindingElement> userBindings = ((UserBindingCollectionElement) collectionElement).Bindings;
Assert.AreEqual (2, userBindings.Count, "Count");
Assert.AreEqual ("UserBinding_1", userBindings [0].Name, "Name_1");
Assert.AreEqual ("UserBinding_2", userBindings [1].Name, "Name_2");
}
}
}

View File

@ -0,0 +1,57 @@
2009-02-24 Atsushi Enomoto <atsushi@ximian.com>
* BindingsSectionTest.cs, ServiceModelSectionGroupTest.cs:
Ignore all failing-under-dotnet tests
2008-04-03 Vladimir Krasnov <vladimirk@mainsoft.com>
* StandardBindingElementCollectionTest.cs: fixed test
2008-04-01 Igor Zelmanovich <igorz@mainsoft.com>
* ServiceElementTest.cs: new test
2008-03-26 Igor Zelmanovich <igorz@mainsoft.com>
* ServiceModelSectionGroupTest.cs: add #if NET_3_5
* CustomBindingElementTest.cs: new test
2008-03-26 Igor Zelmanovich <igorz@mainsoft.com>
* MetadataElementTest.cs: new test
2008-03-04 Eyal Alaluf <eyala@mainsoft.com>
* ServiceModelConfigurationElementCollectionTest.cs: Created file.
* ChannelEndpointElementTest.cs: Created file.
2008-02-19 Igor Zelmanovich <igorz@mainsoft.com>
* MexBindingElementTest.cs: new test
2008-02-19 Igor Zelmanovich <igorz@mainsoft.com>
* StandardBindingCollectionElementTest.cs: add test
2008-02-17 Igor Zelmanovich <igorz@mainsoft.com>
* BasicHttpBindingElementTest.cs:
* NetNamedPipeBindingElementTest.cs:
* NetPeerTcpBindingElementTest.cs:
* NetTcpBindingElementTest.cs:
* ServiceModelSectionGroupTest.cs:
* StandardBindingCollectionElementTest.cs:
new tests.
2008-02-17 Igor Zelmanovich <igorz@mainsoft.com>
* StandardBindingElementCollectionTest.cs new test.
2006-06-27 Atsushi Enomoto <atsushi@ximian.com>
* ServiceModelSectionGroupTest.cs : commented out Endpoints().
It does not work fine on .NET too.
2006-06-27 Atsushi Enomoto <atsushi@ximian.com>
* ServiceModelSectionGroupTest.cs : new test.

View File

@ -0,0 +1,56 @@
//
// ChannelEndpointElementTest.cs
//
// Author:
// Eyal Alaluf <eyala@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ChannelEndpointElementTest
{
[Test]
public void TestEmptyProps ()
{
ChannelEndpointElement empty = new ChannelEndpointElement ();
Assert.AreEqual ("", empty.Name, "#01");
Assert.AreEqual (null, empty.Contract, "#02");
Assert.AreEqual (null, empty.Binding, "#03");
Assert.AreEqual (null, empty.Address, "#04");
Assert.AreEqual ("", empty.BindingConfiguration, "#05");
Assert.AreEqual ("", empty.BehaviorConfiguration, "#06");
Assert.IsNotNull (empty.Headers, "#07");
Assert.IsNotNull (empty.Identity, "#08");
}
}
}

View File

@ -0,0 +1,405 @@
//
// AddressHeaderCollectionElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Configuration;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Net;
using System.ServiceModel;
using System.Net.Security;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class CustomBindingElementTest
{
CustomBindingCollectionElement OpenConfig () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/customBinding").GetSectionGroup ("system.serviceModel");
Assert.AreEqual (7, config.Bindings.CustomBinding.Bindings.Count, "CustomBinding count");
return config.Bindings.CustomBinding;
}
T GetElement<T> (int index) where T : BindingElementExtensionElement {
CustomBindingElement binding = OpenConfig ().Bindings [index];
T element = (T) binding [typeof (T)];
Assert.IsNotNull (element, typeof (T).Name + " is not exist in collection.");
return element;
}
[Test]
public void CustomBindingElement () {
CustomBindingElement binding = OpenConfig ().Bindings [0];
Assert.AreEqual ("CustomBinding_1", binding.Name, "Name");
Assert.AreEqual (new TimeSpan (0, 2, 0), binding.CloseTimeout, "CloseTimeout");
Assert.AreEqual (new TimeSpan (0, 2, 0), binding.OpenTimeout, "OpenTimeout");
Assert.AreEqual (new TimeSpan (0, 20, 0), binding.ReceiveTimeout, "ReceiveTimeout");
Assert.AreEqual (new TimeSpan (0, 2, 0), binding.SendTimeout, "SendTimeout");
}
[Test]
public void BinaryMessageEncodingElement () {
BinaryMessageEncodingElement binaryMessageEncoding = GetElement<BinaryMessageEncodingElement> (0);
Assert.AreEqual (typeof (BinaryMessageEncodingBindingElement), binaryMessageEncoding.BindingElementType, "BindingElementType");
Assert.AreEqual ("binaryMessageEncoding", binaryMessageEncoding.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (128, binaryMessageEncoding.MaxReadPoolSize, "MaxReadPoolSize");
Assert.AreEqual (1024, binaryMessageEncoding.MaxSessionSize, "MaxSessionSize");
Assert.AreEqual (32, binaryMessageEncoding.MaxWritePoolSize, "MaxWritePoolSize");
Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
}
[Test]
public void CompositeDuplexElement () {
CompositeDuplexElement element = GetElement<CompositeDuplexElement> (0);
Assert.AreEqual (typeof (CompositeDuplexBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("compositeDuplex", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual ("http://client.base.address", element.ClientBaseAddress.OriginalString, "ClientBaseAddress");
}
[Test]
public void OneWayElement () {
OneWayElement element = GetElement<OneWayElement> (0);
Assert.AreEqual (typeof (OneWayBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("oneWay", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (5, element.MaxAcceptedChannels, "MaxAcceptedChannels");
Assert.AreEqual (true, element.PacketRoutable, "PacketRoutable");
Assert.AreEqual (new TimeSpan (0, 1, 0), element.ChannelPoolSettings.IdleTimeout, "ChannelPoolSettings.IdleTimeout");
Assert.AreEqual (new TimeSpan (0, 12, 0), element.ChannelPoolSettings.LeaseTimeout, "ChannelPoolSettings.LeaseTimeout");
Assert.AreEqual (5, element.ChannelPoolSettings.MaxOutboundChannelsPerEndpoint, "ChannelPoolSettings.MxOutboundChannelsPerEndpoint");
}
[Test]
public void HttpTransportElement () {
HttpTransportElement element = GetElement<HttpTransportElement> (0);
Assert.AreEqual (typeof (HttpTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("httpTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual (true, element.AllowCookies, "AllowCookies");
Assert.AreEqual (AuthenticationSchemes.None, element.AuthenticationScheme, "AuthenticationScheme");
Assert.AreEqual (true, element.BypassProxyOnLocal, "BypassProxyOnLocal");
Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
Assert.AreEqual (false, element.KeepAliveEnabled, "KeepAliveEnabled");
Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
Assert.AreEqual ("http://proxy.address", element.ProxyAddress.OriginalString, "ProxyAddress");
Assert.AreEqual (AuthenticationSchemes.None, element.ProxyAuthenticationScheme, "ProxyAuthenticationScheme");
Assert.AreEqual ("Realm", element.Realm, "Realm");
Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "TransferMode");
Assert.AreEqual (true, element.UnsafeConnectionNtlmAuthentication, "UnsafeConnectionNtlmAuthentication");
Assert.AreEqual (false, element.UseDefaultWebProxy, "UseDefaultWebProxy");
}
[Test]
public void HttpsTransportElement () {
HttpsTransportElement element = GetElement<HttpsTransportElement> (1);
Assert.AreEqual (typeof (HttpsTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("httpsTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual (true, element.AllowCookies, "AllowCookies");
Assert.AreEqual (AuthenticationSchemes.None, element.AuthenticationScheme, "AuthenticationScheme");
Assert.AreEqual (true, element.BypassProxyOnLocal, "BypassProxyOnLocal");
Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
Assert.AreEqual (true, element.KeepAliveEnabled, "KeepAliveEnabled");
Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
Assert.AreEqual ("https://proxy.address", element.ProxyAddress.OriginalString, "ProxyAddress");
Assert.AreEqual (AuthenticationSchemes.None, element.ProxyAuthenticationScheme, "ProxyAuthenticationScheme");
Assert.AreEqual ("Realm", element.Realm, "Realm");
Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "TransferMode");
Assert.AreEqual (true, element.UnsafeConnectionNtlmAuthentication, "UnsafeConnectionNtlmAuthentication");
Assert.AreEqual (false, element.UseDefaultWebProxy, "UseDefaultWebProxy");
}
[Test]
public void PnrpPeerResolverElement () {
PnrpPeerResolverElement element = GetElement<PnrpPeerResolverElement> (0);
Assert.AreEqual (typeof (PnrpPeerResolverBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("pnrpPeerResolver", element.ConfigurationElementName, "ConfigurationElementName");
}
[Test]
public void PrivacyNoticeElement () {
PrivacyNoticeElement element = GetElement<PrivacyNoticeElement> (0);
Assert.AreEqual (typeof (PrivacyNoticeBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("privacyNoticeAt", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual ("http://url", element.Url.OriginalString, "Url");
Assert.AreEqual (5, element.Version, "Version");
}
[Test]
public void ReliableSessionElement () {
ReliableSessionElement element = GetElement<ReliableSessionElement> (0);
Assert.AreEqual (typeof (ReliableSessionBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("reliableSession", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (TimeSpan.Parse ("00:00:00.4000000"), element.AcknowledgementInterval, "AcknowledgementInterval");
Assert.AreEqual (false, element.FlowControlEnabled, "FlowControlEnabled");
Assert.AreEqual (new TimeSpan (0, 15, 0), element.InactivityTimeout, "InactivityTimeout");
Assert.AreEqual (8, element.MaxPendingChannels, "MaxPendingChannels");
Assert.AreEqual (16, element.MaxRetryCount, "MaxRetryCount");
Assert.AreEqual (16, element.MaxTransferWindowSize, "MaxTransferWindowSize");
Assert.AreEqual (false, element.Ordered, "Ordered");
Assert.AreEqual (ReliableMessagingVersion.WSReliableMessaging11, element.ReliableMessagingVersion, "ReliableMessagingVersion");
}
[Test]
public void SecurityElement () {
SecurityElement element = GetElement<SecurityElement> (0);
Assert.AreEqual (typeof (SecurityBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("security", element.ConfigurationElementName, "ConfigurationElementName");
// TODO
}
[Test]
public void SslStreamSecurityElement () {
SslStreamSecurityElement element = GetElement<SslStreamSecurityElement> (0);
Assert.AreEqual (typeof (SslStreamSecurityBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("sslStreamSecurity", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.RequireClientCertificate, "RequireClientCertificate");
}
[Test]
public void TransactionFlowElement () {
TransactionFlowElement element = GetElement<TransactionFlowElement> (0);
Assert.AreEqual (typeof (TransactionFlowBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("transactionFlow", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (TransactionProtocol.WSAtomicTransactionOctober2004, element.TransactionProtocol, "TransactionProtocol");
}
[Test]
public void UseManagedPresentationElement () {
UseManagedPresentationElement element = GetElement<UseManagedPresentationElement> (0);
Assert.AreEqual (typeof (UseManagedPresentationBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("useManagedPresentation", element.ConfigurationElementName, "ConfigurationElementName");
}
[Test]
public void WindowsStreamSecurityElement () {
WindowsStreamSecurityElement element = GetElement<WindowsStreamSecurityElement> (1);
Assert.AreEqual (typeof (WindowsStreamSecurityBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("windowsStreamSecurity", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (ProtectionLevel.None, element.ProtectionLevel, "ProtectionLevel");
}
[Test]
public void TextMessageEncodingElement () {
TextMessageEncodingElement element = GetElement<TextMessageEncodingElement> (1);
Assert.AreEqual (typeof (TextMessageEncodingBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("textMessageEncoding", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (128, element.MaxReadPoolSize, "MaxReadPoolSize");
Assert.AreEqual (Encoding.UTF32, element.WriteEncoding, "WriteEncoding");
Assert.AreEqual (MessageVersion.Soap11WSAddressingAugust2004, element.MessageVersion, "MessageVersion");
Assert.AreEqual (32, element.MaxWritePoolSize, "MaxWritePoolSize");
Assert.AreEqual (128, element.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
Assert.AreEqual (128, element.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
Assert.AreEqual (128, element.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
Assert.AreEqual (128, element.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
Assert.AreEqual (128, element.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
}
[Test]
public void MtomMessageEncodingElement () {
MtomMessageEncodingElement element = GetElement<MtomMessageEncodingElement> (2);
Assert.AreEqual (typeof (MtomMessageEncodingBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("mtomMessageEncoding", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (128, element.MaxReadPoolSize, "MaxReadPoolSize");
Assert.AreEqual (32, element.MaxWritePoolSize, "MaxWritePoolSize");
Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
Assert.AreEqual (Encoding.UTF32, element.WriteEncoding, "WriteEncoding");
Assert.AreEqual (MessageVersion.Soap11WSAddressingAugust2004, element.MessageVersion, "MessageVersion");
Assert.AreEqual (256, element.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
Assert.AreEqual (256, element.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
Assert.AreEqual (256, element.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
Assert.AreEqual (256, element.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
Assert.AreEqual (256, element.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
}
[Test]
public void MsmqIntegrationElement () {
MsmqIntegrationElement element = GetElement<MsmqIntegrationElement> (2);
Assert.AreEqual (typeof (global::System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("msmqIntegration", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual ("http://CustomDeadLetterQueue", element.CustomDeadLetterQueue.OriginalString, "CustomDeadLetterQueue");
Assert.AreEqual (DeadLetterQueue.Custom, element.DeadLetterQueue, "DeadLetterQueue");
Assert.AreEqual (false, element.Durable, "Durable");
Assert.AreEqual (false, element.ExactlyOnce, "ExactlyOnce");
Assert.AreEqual (3, element.MaxRetryCycles, "MaxRetryCycles");
Assert.AreEqual (ReceiveErrorHandling.Drop, element.ReceiveErrorHandling, "ReceiveErrorHandling");
Assert.AreEqual (10, element.ReceiveRetryCount, "ReceiveRetryCount");
Assert.AreEqual (new TimeSpan (0, 15, 0), element.RetryCycleDelay, "RetryCycleDelay");
Assert.AreEqual (TimeSpan.Parse ("1.12:00:00"), element.TimeToLive, "TimeToLive");
Assert.AreEqual (true, element.UseSourceJournal, "UseSourceJournal");
Assert.AreEqual (true, element.UseMsmqTracing, "UseMsmqTracing");
Assert.AreEqual (global::System.ServiceModel.MsmqIntegration.MsmqMessageSerializationFormat.Binary, element.SerializationFormat, "SerializationFormat");
Assert.AreEqual (MsmqAuthenticationMode.Certificate, element.MsmqTransportSecurity.MsmqAuthenticationMode, "MsmqTransportSecurity.MsmqAuthenticationMode");
Assert.AreEqual (MsmqEncryptionAlgorithm.Aes, element.MsmqTransportSecurity.MsmqEncryptionAlgorithm, "MsmqTransportSecurity.MsmqEncryptionAlgorithm");
Assert.AreEqual (ProtectionLevel.EncryptAndSign, element.MsmqTransportSecurity.MsmqProtectionLevel, "MsmqTransportSecurity.MsmqProtectionLevel");
Assert.AreEqual (MsmqSecureHashAlgorithm.Sha256, element.MsmqTransportSecurity.MsmqSecureHashAlgorithm, "MsmqTransportSecurity.MsmqSecureHashAlgorithm");
}
[Test]
public void MsmqTransportElement () {
MsmqTransportElement element = GetElement<MsmqTransportElement> (3);
Assert.AreEqual (typeof (MsmqTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("msmqTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (262144, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual ("http://CustomDeadLetterQueue", element.CustomDeadLetterQueue.OriginalString, "CustomDeadLetterQueue");
Assert.AreEqual (DeadLetterQueue.Custom, element.DeadLetterQueue, "DeadLetterQueue");
Assert.AreEqual (false, element.Durable, "Durable");
Assert.AreEqual (false, element.ExactlyOnce, "ExactlyOnce");
Assert.AreEqual (3, element.MaxRetryCycles, "MaxRetryCycles");
Assert.AreEqual (ReceiveErrorHandling.Drop, element.ReceiveErrorHandling, "ReceiveErrorHandling");
Assert.AreEqual (9, element.ReceiveRetryCount, "ReceiveRetryCount");
Assert.AreEqual (new TimeSpan (0, 15, 0), element.RetryCycleDelay, "RetryCycleDelay");
Assert.AreEqual (TimeSpan.Parse ("1.12:00:00"), element.TimeToLive, "TimeToLive");
Assert.AreEqual (true, element.UseSourceJournal, "UseSourceJournal");
Assert.AreEqual (true, element.UseMsmqTracing, "UseMsmqTracing");
Assert.AreEqual (MsmqAuthenticationMode.Certificate, element.MsmqTransportSecurity.MsmqAuthenticationMode, "MsmqTransportSecurity.MsmqAuthenticationMode");
Assert.AreEqual (MsmqEncryptionAlgorithm.Aes, element.MsmqTransportSecurity.MsmqEncryptionAlgorithm, "MsmqTransportSecurity.MsmqEncryptionAlgorithm");
Assert.AreEqual (ProtectionLevel.EncryptAndSign, element.MsmqTransportSecurity.MsmqProtectionLevel, "MsmqTransportSecurity.MsmqProtectionLevel");
Assert.AreEqual (MsmqSecureHashAlgorithm.Sha256, element.MsmqTransportSecurity.MsmqSecureHashAlgorithm, "MsmqTransportSecurity.MsmqSecureHashAlgorithm");
}
[Test]
public void NamedPipeTransportElement () {
NamedPipeTransportElement element = GetElement<NamedPipeTransportElement> (4);
Assert.AreEqual (typeof (NamedPipeTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("namedPipeTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual (4096, element.ConnectionBufferSize, "ConnectionBufferSize");
Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
Assert.AreEqual (new TimeSpan (0, 0, 20), element.ChannelInitializationTimeout, "ChannelInitializationTimeout");
Assert.AreEqual (5, element.MaxPendingConnections, "MaxPendingConnections");
Assert.AreEqual (TimeSpan.Parse ("00:00:01.2000000"), element.MaxOutputDelay, "MaxOutputDelay");
Assert.AreEqual (3, element.MaxPendingAccepts, "MaxPendingAccepts");
Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "MaxPendingAccepts");
Assert.AreEqual ("GroupName", element.ConnectionPoolSettings.GroupName, "ConnectionPoolSettings.GroupName");
Assert.AreEqual (new TimeSpan (0, 6, 0), element.ConnectionPoolSettings.IdleTimeout, "ConnectionPoolSettings.IdleTimeout");
Assert.AreEqual (20, element.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint, "ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint");
}
[Test]
public void TcpTransportElement () {
TcpTransportElement element = GetElement<TcpTransportElement> (5);
Assert.AreEqual (typeof (TcpTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("tcpTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual (4096, element.ConnectionBufferSize, "ConnectionBufferSize");
Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
Assert.AreEqual (new TimeSpan (0, 0, 15), element.ChannelInitializationTimeout, "ChannelInitializationTimeout");
Assert.AreEqual (20, element.MaxPendingConnections, "MaxPendingConnections");
Assert.AreEqual (TimeSpan.Parse ("00:00:01.2000000"), element.MaxOutputDelay, "MaxOutputDelay");
Assert.AreEqual (3, element.MaxPendingAccepts, "MaxPendingAccepts");
Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "MaxPendingAccepts");
Assert.AreEqual (20, element.ListenBacklog, "ListenBacklog");
Assert.AreEqual (true, element.PortSharingEnabled, "PortSharingEnabled");
Assert.AreEqual (true, element.TeredoEnabled, "TeredoEnabled");
Assert.AreEqual ("GroupName", element.ConnectionPoolSettings.GroupName, "ConnectionPoolSettings.GroupName");
Assert.AreEqual (new TimeSpan (0, 15, 0), element.ConnectionPoolSettings.LeaseTimeout, "ConnectionPoolSettings.LeaseTimeout");
Assert.AreEqual (new TimeSpan (0, 2, 30), element.ConnectionPoolSettings.IdleTimeout, "ConnectionPoolSettings.IdleTimeout");
Assert.AreEqual (30, element.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint, "ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint");
}
[Test]
public void PeerTransportElement () {
PeerTransportElement element = GetElement<PeerTransportElement> (6);
Assert.AreEqual (typeof (PeerTransportBindingElement), element.BindingElementType, "BindingElementType");
Assert.AreEqual ("peerTransport", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
Assert.AreEqual (IPAddress.Parse ("192.168.0.1"), element.ListenIPAddress, "ListenIPAddress");
Assert.AreEqual (88, element.Port, "Port");
Assert.AreEqual (SecurityMode.Message, element.Security.Mode, "Security.Mode");
Assert.AreEqual (PeerTransportCredentialType.Certificate, element.Security.Transport.CredentialType, "Security.Transport.CredentialType");
}
}
}

View File

@ -0,0 +1,262 @@
//
// EndpointBehaviorElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.Configuration;
using System.ServiceModel.Description;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Security;
using System.Security.Principal;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class EndpointBehaviorElementTest
{
EndpointBehaviorElement OpenConfig () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/endpointBehaviors").GetSectionGroup ("system.serviceModel");
return config.Behaviors.EndpointBehaviors [0];
}
[Test]
public void CallbackDebugElement () {
EndpointBehaviorElement behavior = OpenConfig ();
CallbackDebugElement callbackDebug = (CallbackDebugElement) behavior [typeof (CallbackDebugElement)];
if (callbackDebug == null)
Assert.Fail ("CallbackDebugElement is not exist in collection.");
Assert.AreEqual (typeof (CallbackDebugBehavior), callbackDebug.BehaviorType, "RoleProviderName");
Assert.AreEqual ("callbackDebug", callbackDebug.ConfigurationElementName, "RoleProviderName");
Assert.AreEqual (true, callbackDebug.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
}
[Test]
public void CallbackDebugElement_defaults () {
CallbackDebugElement element = new CallbackDebugElement ();
Assert.AreEqual (typeof (CallbackDebugBehavior), element.BehaviorType, "element");
Assert.AreEqual ("callbackDebug", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
}
[Test]
public void CallbackTimeoutsElement () {
EndpointBehaviorElement behavior = OpenConfig ();
CallbackTimeoutsElement element = (CallbackTimeoutsElement) behavior [typeof (CallbackTimeoutsElement)];
if (element == null)
Assert.Fail ("CallbackTimeoutsElement is not exist in collection.");
Assert.AreEqual ("System.ServiceModel.Description.CallbackTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("callbackTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (new TimeSpan (0, 2, 30), element.TransactionTimeout, "TransactionTimeout");
}
[Test]
public void CallbackTimeoutsElement_defaults () {
CallbackTimeoutsElement element = new CallbackTimeoutsElement ();
Assert.AreEqual ("System.ServiceModel.Description.CallbackTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("callbackTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
}
[Test]
public void ClientViaElement () {
EndpointBehaviorElement behavior = OpenConfig ();
ClientViaElement element = (ClientViaElement) behavior [typeof (ClientViaElement)];
if (element == null)
Assert.Fail ("ClientViaElement is not exist in collection.");
Assert.AreEqual (typeof (ClientViaBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("clientVia", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual ("http://via.uri", element.ViaUri.OriginalString, "ViaUri");
}
[Test]
public void ClientViaElement_defaults () {
ClientViaElement element = new ClientViaElement ();
Assert.AreEqual (typeof (ClientViaBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("clientVia", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (null, element.ViaUri, "ViaUri");
}
[Test]
public void DataContractSerializerElement () {
EndpointBehaviorElement behavior = OpenConfig ();
DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
if (element == null)
Assert.Fail ("DataContractSerializerElement is not exist in collection.");
Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
}
[Test]
public void DataContractSerializerElement_defaults () {
DataContractSerializerElement element = new DataContractSerializerElement ();
Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
}
[Test]
public void SynchronousReceiveElement () {
EndpointBehaviorElement behavior = OpenConfig ();
SynchronousReceiveElement element = (SynchronousReceiveElement) behavior [typeof (SynchronousReceiveElement)];
if (element == null)
Assert.Fail ("SynchronousReceiveElement is not exist in collection.");
Assert.AreEqual (typeof (SynchronousReceiveBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("synchronousReceive", element.ConfigurationElementName, "ConfigurationElementName");
}
[Test]
public void SynchronousReceiveElement_defaults () {
SynchronousReceiveElement element = new SynchronousReceiveElement ();
Assert.AreEqual (typeof (SynchronousReceiveBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("synchronousReceive", element.ConfigurationElementName, "ConfigurationElementName");
}
[Test]
public void TransactedBatchingElement () {
EndpointBehaviorElement behavior = OpenConfig ();
TransactedBatchingElement element = (TransactedBatchingElement) behavior [typeof (TransactedBatchingElement)];
if (element == null)
Assert.Fail ("TransactedBatchingElement is not exist in collection.");
Assert.AreEqual (typeof (TransactedBatchingBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("transactedBatching", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (16, element.MaxBatchSize, "MaxBatchSize");
}
[Test]
public void TransactedBatchingElement_defaults () {
TransactedBatchingElement element = new TransactedBatchingElement ();
Assert.AreEqual (typeof (TransactedBatchingBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("transactedBatching", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (0, element.MaxBatchSize, "MaxBatchSize");
}
[Test]
public void ClientCredentialsElement () {
EndpointBehaviorElement behavior = OpenConfig ();
ClientCredentialsElement element = (ClientCredentialsElement) behavior [typeof (ClientCredentialsElement)];
if (element == null)
Assert.Fail ("ClientCredentialsElement is not exist in collection.");
Assert.AreEqual (typeof (ClientCredentials), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("clientCredentials", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.SupportInteractive, "SupportInteractive");
Assert.AreEqual ("ClientCredentialType", element.Type, "Type");
Assert.AreEqual ("findValue", element.ClientCertificate.FindValue, "ClientCertificate.FindValue");
Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.StoreLocation, "ClientCertificate.StoreLocation");
Assert.AreEqual (StoreName.Root, element.ClientCertificate.StoreName, "ClientCertificate.StoreName");
Assert.AreEqual (X509FindType.FindByExtension, element.ClientCertificate.X509FindType, "ClientCertificate.X509FindType");
Assert.AreEqual ("findValue", element.ServiceCertificate.DefaultCertificate.FindValue, "ServiceCertificate.DefaultCertificate.FindValue");
Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.DefaultCertificate.StoreLocation, "ServiceCertificate.DefaultCertificate.StoreLocation");
Assert.AreEqual (StoreName.Root, element.ServiceCertificate.DefaultCertificate.StoreName, "ServiceCertificate.DefaultCertificate.StoreName");
Assert.AreEqual (X509FindType.FindByExtension, element.ServiceCertificate.DefaultCertificate.X509FindType, "ServiceCertificate.DefaultCertificate.X509FindType");
Assert.AreEqual ("CustomCertificateValidatorType", element.ServiceCertificate.Authentication.CustomCertificateValidatorType, "ServiceCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.None, element.ServiceCertificate.Authentication.CertificateValidationMode, "ServiceCertificate.Authentication.CertificateValidationMode");
Assert.AreEqual (X509RevocationMode.Offline, element.ServiceCertificate.Authentication.RevocationMode, "ServiceCertificate.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.Authentication.TrustedStoreLocation, "ServiceCertificate.Authentication.TrustedStoreLocation");
Assert.AreEqual (false, element.Windows.AllowNtlm, "Windows.AllowNtlm");
Assert.AreEqual (TokenImpersonationLevel.None, element.Windows.AllowedImpersonationLevel, "Windows.AllowedImpersonationLevel");
Assert.AreEqual (false, element.IssuedToken.CacheIssuedTokens, "IssuedToken.CacheIssuedTokens");
Assert.AreEqual (SecurityKeyEntropyMode.ClientEntropy, element.IssuedToken.DefaultKeyEntropyMode, "IssuedToken.DefaultKeyEntropyMode");
Assert.AreEqual (30, element.IssuedToken.IssuedTokenRenewalThresholdPercentage, "IssuedToken.IssuedTokenRenewalThresholdPercentage");
Assert.AreEqual (TokenImpersonationLevel.None, element.HttpDigest.ImpersonationLevel, "HttpDigest.ImpersonationLevel");
}
[Test]
public void ClientCredentialsElement_defaults () {
ClientCredentialsElement element = new ClientCredentialsElement ();
Assert.AreEqual (typeof (ClientCredentials), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("clientCredentials", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.SupportInteractive, "SupportInteractive");
Assert.AreEqual (String.Empty, element.Type, "Type");
Assert.AreEqual (String.Empty, element.ClientCertificate.FindValue, "ClientCertificate.FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.StoreLocation, "ClientCertificate.StoreLocation");
Assert.AreEqual (StoreName.My, element.ClientCertificate.StoreName, "ClientCertificate.StoreName");
Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.X509FindType, "ClientCertificate.X509FindType");
Assert.AreEqual (String.Empty, element.ServiceCertificate.DefaultCertificate.FindValue, "ServiceCertificate.DefaultCertificate.FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.DefaultCertificate.StoreLocation, "ServiceCertificate.DefaultCertificate.StoreLocation");
Assert.AreEqual (StoreName.My, element.ServiceCertificate.DefaultCertificate.StoreName, "ServiceCertificate.DefaultCertificate.StoreName");
Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.DefaultCertificate.X509FindType, "ServiceCertificate.DefaultCertificate.X509FindType");
Assert.AreEqual (String.Empty, element.ServiceCertificate.Authentication.CustomCertificateValidatorType, "ServiceCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ServiceCertificate.Authentication.CertificateValidationMode, "ServiceCertificate.Authentication.CertificateValidationMode");
Assert.AreEqual (X509RevocationMode.Online, element.ServiceCertificate.Authentication.RevocationMode, "ServiceCertificate.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.Authentication.TrustedStoreLocation, "ServiceCertificate.Authentication.TrustedStoreLocation");
Assert.AreEqual (true, element.Windows.AllowNtlm, "Windows.AllowNtlm");
Assert.AreEqual (TokenImpersonationLevel.Identification, element.Windows.AllowedImpersonationLevel, "Windows.AllowedImpersonationLevel");
Assert.AreEqual (true, element.IssuedToken.CacheIssuedTokens, "IssuedToken.CacheIssuedTokens");
Assert.AreEqual (SecurityKeyEntropyMode.CombinedEntropy, element.IssuedToken.DefaultKeyEntropyMode, "IssuedToken.DefaultKeyEntropyMode");
Assert.AreEqual (60, element.IssuedToken.IssuedTokenRenewalThresholdPercentage, "IssuedToken.IssuedTokenRenewalThresholdPercentage");
Assert.AreEqual (TokenImpersonationLevel.Identification, element.HttpDigest.ImpersonationLevel, "HttpDigest.ImpersonationLevel");
}
}
}

View File

@ -0,0 +1,93 @@
//
// ExtensionsSectionTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel.Configuration;
using System.Configuration;
using NUnit.Framework;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ExtensionsSectionTest
{
class Poker : ExtensionsSection
{
public ConfigurationPropertyCollection GetProperties () {
return Properties;
}
[ConfigurationProperty ("myProperty")]
string MyProperty {
get { return "myProperty"; }
set { }
}
}
[Test]
public void Properties () {
Poker p1 = new Poker ();
Poker p2 = new Poker ();
Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
}
[Test]
public void BindingExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (BasicHttpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["basicHttpBinding"].Type, "baseHttpBinding");
Assert.AreEqual (typeof (NetTcpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["netTcpBinding"].Type, "baseHttpBinding");
Assert.AreEqual (typeof (CustomBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["customBinding"].Type, "baseHttpBinding");
Assert.AreEqual ("MyBindingCollectionElement", config.Extensions.BindingExtensions ["bindingExtensions1"].Type, "MyBindingCollectionElement");
Assert.AreEqual ("AnotherBindingCollectionElement", config.Extensions.BindingExtensions ["bindingExtensions2"].Type, "AnotherBindingCollectionElement");
}
[Test]
public void BehaviorExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (ServiceAuthorizationElement).AssemblyQualifiedName, config.Extensions.BehaviorExtensions ["serviceAuthorization"].Type, "serviceAuthorization");
Assert.AreEqual ("MyBehaviorElement", config.Extensions.BehaviorExtensions ["behaviorExtensions1"].Type, "MyBehaviorElement");
Assert.AreEqual ("AnotherBehaviorElement", config.Extensions.BehaviorExtensions ["behaviorExtensions2"].Type, "AnotherBehaviorElement");
}
[Test]
public void BindingElementExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (BinaryMessageEncodingElement).AssemblyQualifiedName, config.Extensions.BindingElementExtensions ["binaryMessageEncoding"].Type, "binaryMessageEncoding");
Assert.AreEqual ("MyBindingElementElement", config.Extensions.BindingElementExtensions ["bindingElementExtensions1"].Type, "MyBindingElementElement");
Assert.AreEqual ("AnotherBindingElementElement", config.Extensions.BindingElementExtensions ["bindingElementExtensions2"].Type, "AnotherBindingElementElement");
}
}
}

View File

@ -0,0 +1,134 @@
//
// MetadataElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class MetadataElementTest
{
ServiceModelSectionGroup OpenConfig (string name) {
return (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/" + name).GetSectionGroup ("system.serviceModel");
}
[Test]
public void PolicyImporters () {
ServiceModelSectionGroup config = OpenConfig ("client.metadata");
PolicyImporterElementCollection col = config.Client.Metadata.PolicyImporters;
Assert.AreEqual (2, col.Count, "Count");
PolicyImporterElement item = col ["PolicyImporterType1"];
if (item == null)
Assert.Fail ("PolicyImporterType1 not exists");
Assert.AreEqual ("PolicyImporterType1", item.Type, "PolicyImporterType1.Type");
item = col ["PolicyImporterType2"];
if (item == null)
Assert.Fail ("PolicyImporterType2 not exists");
Assert.AreEqual ("PolicyImporterType2", item.Type, "PolicyImporterType2.Type");
}
[Test]
public void WsdlImporters () {
ServiceModelSectionGroup config = OpenConfig ("client.metadata");
WsdlImporterElementCollection col = config.Client.Metadata.WsdlImporters;
Assert.AreEqual (2, col.Count, "Count");
WsdlImporterElement item = col ["WSDLImporter1"];
if (item == null)
Assert.Fail ("WSDLImporter1 not exists");
Assert.AreEqual ("WSDLImporter1", item.Type, "WSDLImporter1.Type");
item = col ["WSDLImporter2"];
if (item == null)
Assert.Fail ("WSDLImporter2 not exists");
Assert.AreEqual ("WSDLImporter2", item.Type, "WSDLImporter2.Type");
}
[Test]
public void PolicyImporters_DefaultConfiguration () {
ServiceModelSectionGroup config = OpenConfig ("empty");
PolicyImporterElementCollection col = config.Client.Metadata.PolicyImporters;
Type [] types = new Type [] {
typeof(CompositeDuplexBindingElementImporter),
typeof(MessageEncodingBindingElementImporter),
typeof(OneWayBindingElementImporter),
typeof(PrivacyNoticeBindingElementImporter),
typeof(ReliableSessionBindingElementImporter),
typeof(SecurityBindingElementImporter),
typeof(TransactionFlowBindingElementImporter),
typeof(TransportBindingElementImporter),
typeof(UseManagedPresentationBindingElementImporter)
};
foreach (Type type in types) {
PolicyImporterElement item = col [type.AssemblyQualifiedName];
if (item == null)
Assert.Fail (type.Name + " not exists");
Assert.AreEqual (type.AssemblyQualifiedName, item.Type, type.Name);
}
}
[Test]
public void WsdlImporters_DefaultConfiguration () {
ServiceModelSectionGroup config = OpenConfig ("empty");
WsdlImporterElementCollection col = config.Client.Metadata.WsdlImporters;
Type [] types = new Type [] {
typeof(MessageEncodingBindingElementImporter),
typeof(StandardBindingImporter),
typeof(TransportBindingElementImporter),
typeof(DataContractSerializerMessageContractImporter),
typeof(XmlSerializerMessageContractImporter)
};
foreach (Type type in types) {
WsdlImporterElement item = col [type.AssemblyQualifiedName];
if (item == null)
Assert.Fail (type.Name + " not exists");
Assert.AreEqual (type.AssemblyQualifiedName, item.Type, type.Name);
}
}
}
}

View File

@ -0,0 +1,58 @@
//
// MexBindingElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class MexBindingElementTest
{
class Poker<TStandardBinding> : MexBindingElement<TStandardBinding> where TStandardBinding : Binding
{
public Poker (string name)
: base (name) {
}
public Type GetBindingElementType () {
return BindingElementType;
}
}
[Test]
public void BindingElementType () {
Poker<CustomBinding> poker = new Poker<CustomBinding> ("kuku");
Assert.AreEqual (typeof (CustomBinding), poker.GetBindingElementType (), "BindingElementType");
}
}
}

View File

@ -0,0 +1,54 @@
//
// NetNamedPipeBindingElement.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class NetNamedPipeBindingElementTest
{
class Poker : NetNamedPipeBindingElement
{
public Type GetBindingElementType () {
return BindingElementType;
}
}
[Test]
public void BindingElementType () {
Poker poker = new Poker ();
Assert.AreEqual (typeof (NetNamedPipeBinding), poker.GetBindingElementType (), "BindingElementType");
}
}
}

View File

@ -0,0 +1,54 @@
//
// NetPeerTcpBindingElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class NetPeerTcpBindingElementTest
{
class Poker : NetPeerTcpBindingElement
{
public Type GetBindingElementType () {
return BindingElementType;
}
}
[Test]
public void BindingElementType () {
Poker poker = new Poker ();
Assert.AreEqual (typeof (NetPeerTcpBinding), poker.GetBindingElementType (), "BindingElementType");
}
}
}

View File

@ -0,0 +1,54 @@
//
// NetTcpBindingElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class NetTcpBindingElementTest
{
class Poker : NetTcpBindingElement
{
public Type GetBindingElementType () {
return BindingElementType;
}
}
[Test]
public void BindingElementType () {
Poker poker = new Poker ();
Assert.AreEqual (typeof (NetTcpBinding), poker.GetBindingElementType (), "BindingElementType");
}
}
}

View File

@ -0,0 +1,389 @@
//
// ServiceBehaviorElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.Configuration;
using System.ServiceModel;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Security;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ServiceBehaviorElementTest
{
ServiceBehaviorElement OpenConfig () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/serviceBehaviors").GetSectionGroup ("system.serviceModel");
return config.Behaviors.ServiceBehaviors [0];
}
[Test]
public void ServiceAuthorizationElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceAuthorizationElement serviceAuthorization = (ServiceAuthorizationElement) behavior [typeof (ServiceAuthorizationElement)];
if (serviceAuthorization == null)
Assert.Fail ("ServiceAuthorizationElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual ("RoleProvider", serviceAuthorization.RoleProviderName, "RoleProviderName");
Assert.AreEqual (PrincipalPermissionMode.UseAspNetRoles, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
Assert.AreEqual (true, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
Assert.AreEqual ("SerAuthManagType", serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
Assert.AreEqual (2, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
Assert.AreEqual ("PolicyType1", serviceAuthorization.AuthorizationPolicies [0].PolicyType, "AuthorizationPolicies[0].PolicyType");
Assert.AreEqual ("PolicyType2", serviceAuthorization.AuthorizationPolicies [1].PolicyType, "AuthorizationPolicies[1].PolicyType");
}
[Test]
public void ServiceAuthorizationElement_default () {
ServiceAuthorizationElement serviceAuthorization = new ServiceAuthorizationElement ();
Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (String.Empty, serviceAuthorization.RoleProviderName, "RoleProviderName");
Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
Assert.AreEqual (false, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
Assert.AreEqual (String.Empty, serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
Assert.AreEqual (0, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
}
[Test]
public void DataContractSerializerElement () {
ServiceBehaviorElement behavior = OpenConfig ();
DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
if (element == null)
Assert.Fail ("DataContractSerializerElement is not exist in collection.");
Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
}
[Test]
public void DataContractSerializerElement_defaults () {
DataContractSerializerElement element = new DataContractSerializerElement ();
Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
}
[Test]
public void ServiceDebugElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceDebugElement element = (ServiceDebugElement) behavior [typeof (ServiceDebugElement)];
if (element == null)
Assert.Fail ("ServiceDebugElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
Assert.AreEqual ("http://help.page.url", element.HttpHelpPageUrl.OriginalString, "HttpHelpPageUrl");
Assert.AreEqual (false, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
Assert.AreEqual ("https://help.page.url", element.HttpsHelpPageUrl.OriginalString, "HttpsHelpPageUrl");
Assert.AreEqual (true, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
}
[Test]
public void ServiceDebugElement_defaults () {
ServiceDebugElement element = new ServiceDebugElement ();
Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
Assert.AreEqual (null, element.HttpHelpPageUrl, "HttpHelpPageUrl");
Assert.AreEqual (true, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
Assert.AreEqual (null, element.HttpsHelpPageUrl, "HttpsHelpPageUrl");
Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
}
[Test]
public void ServiceMetadataPublishingElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceMetadataPublishingElement element = (ServiceMetadataPublishingElement) behavior [typeof (ServiceMetadataPublishingElement)];
if (element == null)
Assert.Fail ("ServiceMetadataPublishingElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (true, element.HttpGetEnabled, "HttpGetEnabled");
Assert.AreEqual ("http://get.url", element.HttpGetUrl.OriginalString, "HttpGetUrl");
Assert.AreEqual (true, element.HttpsGetEnabled, "HttpsGetEnabled");
Assert.AreEqual ("https://get.url", element.HttpsGetUrl.OriginalString, "HttpsHelpPageUrl");
Assert.AreEqual ("http://external.metadata.location", element.ExternalMetadataLocation.OriginalString, "ExternalMetadataLocation");
Assert.AreEqual (PolicyVersion.Policy12, element.PolicyVersion, "PolicyVersion");
}
[Test]
public void ServiceMetadataPublishingElement_defaults () {
ServiceMetadataPublishingElement element = new ServiceMetadataPublishingElement ();
Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (false, element.HttpGetEnabled, "HttpGetEnabled");
Assert.AreEqual (null, element.HttpGetUrl, "HttpGetUrl");
Assert.AreEqual (false, element.HttpsGetEnabled, "HttpsGetEnabled");
Assert.AreEqual (null, element.HttpsGetUrl, "HttpsGetUrl");
Assert.AreEqual (null, element.ExternalMetadataLocation, "ExternalMetadataLocation");
Assert.AreEqual (PolicyVersion.Default, element.PolicyVersion, "PolicyVersion");
}
[Test]
public void ServiceSecurityAuditElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceSecurityAuditElement element = (ServiceSecurityAuditElement) behavior [typeof (ServiceSecurityAuditElement)];
if (element == null)
Assert.Fail ("ServiceSecurityAuditElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (AuditLogLocation.Application, element.AuditLogLocation, "AuditLogLocation");
Assert.AreEqual (false, element.SuppressAuditFailure, "SuppressAuditFailure");
Assert.AreEqual (AuditLevel.Success, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
Assert.AreEqual (AuditLevel.Success, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
}
[Test]
public void ServiceSecurityAuditElement_defaults () {
ServiceSecurityAuditElement element = new ServiceSecurityAuditElement ();
Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (AuditLogLocation.Default, element.AuditLogLocation, "AuditLogLocation");
Assert.AreEqual (true, element.SuppressAuditFailure, "SuppressAuditFailure");
Assert.AreEqual (AuditLevel.None, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
Assert.AreEqual (AuditLevel.None, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
}
[Test]
public void ServiceThrottlingElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceThrottlingElement element = (ServiceThrottlingElement) behavior [typeof (ServiceThrottlingElement)];
if (element == null)
Assert.Fail ("ServiceThrottlingElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (32, element.MaxConcurrentCalls, "MaxConcurrentCalls");
Assert.AreEqual (20, element.MaxConcurrentSessions, "MaxConcurrentSessions");
Assert.AreEqual (14, element.MaxConcurrentInstances, "MaxConcurrentInstances");
}
[Test]
public void ServiceThrottlingElement_defaults () {
ServiceThrottlingElement element = new ServiceThrottlingElement ();
Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (16, element.MaxConcurrentCalls, "MaxConcurrentCalls");
Assert.AreEqual (10, element.MaxConcurrentSessions, "MaxConcurrentSessions");
Assert.AreEqual (26, element.MaxConcurrentInstances, "MaxConcurrentInstances");
}
[Test]
public void ServiceTimeoutsElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceTimeoutsElement element = (ServiceTimeoutsElement) behavior [typeof (ServiceTimeoutsElement)];
if (element == null)
Assert.Fail ("ServiceTimeoutsElement is not exist in collection.");
Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (new TimeSpan (0, 3, 0), element.TransactionTimeout, "TransactionTimeout");
}
[Test]
public void ServiceTimeoutsElement_defaults () {
ServiceTimeoutsElement element = new ServiceTimeoutsElement ();
Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
}
[Test]
public void ServiceCredentialsElement () {
ServiceBehaviorElement behavior = OpenConfig ();
ServiceCredentialsElement element = (ServiceCredentialsElement) behavior [typeof (ServiceCredentialsElement)];
if (element == null)
Assert.Fail ("ServiceCredentialsElement is not exist in collection.");
Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual ("ServiceCredentialsType", element.Type, "Type");
Assert.AreEqual ("FindValue", element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
Assert.AreEqual (StoreName.Root, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
Assert.AreEqual (X509FindType.FindByIssuerName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
Assert.AreEqual ("CustomCertificateValidationType", element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Offline, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
Assert.AreEqual (false, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
Assert.AreEqual (true, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
Assert.AreEqual ("FindValue", element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
Assert.AreEqual (StoreName.Root, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
Assert.AreEqual (X509FindType.FindByIssuerName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
Assert.AreEqual (UserNamePasswordValidationMode.MembershipProvider, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
Assert.AreEqual (false, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
Assert.AreEqual ("MembershipProviderName", element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
Assert.AreEqual ("CustomUserNamePasswordValidatorType", element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
Assert.AreEqual (true, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
Assert.AreEqual (252, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
Assert.AreEqual (new TimeSpan (0, 30, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
Assert.AreEqual ("FindValue", element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
Assert.AreEqual (StoreName.Root, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
Assert.AreEqual (X509FindType.FindByIssuerName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.Custom, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Offline, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.None, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Offline, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
Assert.AreEqual ("CustomCertificateValidatorType", element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Offline, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
Assert.AreEqual ("SalmSerializerType", element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
Assert.AreEqual (true, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
Assert.AreEqual ("FindValue", element.IssuedTokenAuthentication.KnownCertificates [0].FindValue, "IssuedTokenAuthentication.KnownCertificates[0].FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.KnownCertificates [0].StoreLocation, "IssuedTokenAuthentication.KnownCertificates[0].StoreLocation");
Assert.AreEqual (StoreName.Root, element.IssuedTokenAuthentication.KnownCertificates [0].StoreName, "IssuedTokenAuthentication.KnownCertificates[0].StoreName");
Assert.AreEqual (X509FindType.FindByIssuerName, element.IssuedTokenAuthentication.KnownCertificates [0].X509FindType, "IssuedTokenAuthentication.KnownCertificates[0].X509FindType");
Assert.AreEqual ("SecurityStateEncoderType", element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
}
[Test]
public void ServiceCredentialsElement_defaults () {
ServiceCredentialsElement element = new ServiceCredentialsElement ();
Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
Assert.AreEqual (String.Empty, element.Type, "Type");
Assert.AreEqual (String.Empty, element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
Assert.AreEqual (StoreName.My, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
Assert.AreEqual (String.Empty, element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Online, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
Assert.AreEqual (true, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
Assert.AreEqual (false, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
Assert.AreEqual (String.Empty, element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
Assert.AreEqual (StoreName.My, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
Assert.AreEqual (UserNamePasswordValidationMode.Windows, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
Assert.AreEqual (true, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
Assert.AreEqual (String.Empty, element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
Assert.AreEqual (String.Empty, element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
Assert.AreEqual (false, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
Assert.AreEqual (128, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
Assert.AreEqual (new TimeSpan (0, 15, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
Assert.AreEqual (String.Empty, element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
Assert.AreEqual (StoreName.My, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
Assert.AreEqual (String.Empty, element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Online, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
Assert.AreEqual (String.Empty, element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Online, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
Assert.AreEqual (X509RevocationMode.Online, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
Assert.AreEqual (StoreLocation.LocalMachine, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
Assert.AreEqual (false, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
Assert.AreEqual (0, element.IssuedTokenAuthentication.KnownCertificates.Count, "IssuedTokenAuthentication.KnownCertificates.Count");
Assert.AreEqual (String.Empty, element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
}
}
}

View File

@ -0,0 +1,86 @@
//
// ServiceElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ServiceElementTest
{
[Test]
public void ReadConfiguration () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/service").GetSectionGroup ("system.serviceModel");
ServiceElement service = config.Services.Services [0];
Assert.AreEqual ("ServiceType", service.Name, "Name");
Assert.AreEqual ("", service.BehaviorConfiguration, "BehaviorConfiguration");
Assert.AreEqual (3, service.Endpoints.Count, "Endpoints.Count");
Assert.AreEqual ("basicHttp", service.Endpoints [0].Name, "Endpoints [0].Name");
Assert.AreEqual ("basicHttpBinding", service.Endpoints [0].Binding, "Endpoints [0].Binding");
Assert.AreEqual ("HttpServiceContract", service.Endpoints [0].Contract, "Endpoints [0].Contract");
Assert.AreEqual ("/rooted.path", service.Endpoints [0].Address.OriginalString, "Endpoints [0].Address");
Assert.AreEqual (1, service.Endpoints [0].Headers.Headers.Count, "Endpoints [0].Headers.Headers.Count");
Assert.AreEqual ("Tag", service.Endpoints [0].Headers.Headers [0].Name, "Endpoints [0].Headers.Headers[0].Name");
Assert.AreEqual ("", service.Endpoints [0].Headers.Headers [0].Namespace, "Endpoints [0].Headers.Headers[0].Namespace");
Assert.AreEqual ("", service.Endpoints [1].Name, "Endpoints [1].Name");
Assert.AreEqual ("wsHttpBinding", service.Endpoints [1].Binding, "Endpoints [1].Binding");
Assert.AreEqual ("WSServiceContract", service.Endpoints [1].Contract, "Endpoints [1].Contract");
Assert.AreEqual ("http://other.endpoint.com", service.Endpoints [1].Address.OriginalString, "Endpoints [1].Address");
Assert.AreEqual ("netTcp", service.Endpoints [2].Name, "Endpoints [2].Name");
Assert.AreEqual ("netTcpBinding", service.Endpoints [2].Binding, "Endpoints [2].Binding");
Assert.AreEqual ("TcpServiceContract", service.Endpoints [2].Contract, "Endpoints [2].Contract");
Assert.AreEqual ("path", service.Endpoints [2].Address.OriginalString, "Endpoints [2].Address");
Assert.AreEqual (new TimeSpan (0, 0, 20), service.Host.Timeouts.CloseTimeout, "Host.Timeouts.CloseTimeout");
Assert.AreEqual (new TimeSpan (0, 2, 0), service.Host.Timeouts.OpenTimeout, "Host.Timeouts.OpenTimeout");
Assert.AreEqual (2, service.Host.BaseAddresses.Count, "Host.BaseAddresses.Count");
Assert.AreEqual ("http://endpoint.com/some.path", service.Host.BaseAddresses [0].BaseAddress, "Host.BaseAddresses[0].BaseAddress");
Assert.AreEqual ("net.tcp://endpoint.com", service.Host.BaseAddresses [1].BaseAddress, "Host.BaseAddresses[1].BaseAddress");
}
[Test]
public void ServiceEndpointCollection () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/service").GetSectionGroup ("system.serviceModel");
ServiceElement service = config.Services.Services [1];
Assert.AreEqual (3, service.Endpoints.Count, "Count");
}
}
}

View File

@ -0,0 +1,132 @@
//
// ServiceModelConfigurationElementCollectionTest.cs
//
// Author:
// Eyal Alaluf <eyala@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ServiceModelConfigurationElementCollectionTest
{
ClaimTypeElementCollection collection;
private ClaimTypeElement CreateClaimType (string claim, bool isOptional)
{
ClaimTypeElement elem = new ClaimTypeElement ();
elem.ClaimType = claim;
elem.IsOptional = isOptional;
return elem;
}
[TearDown]
public void TearDownCollection ()
{
collection = null;
}
[SetUp]
public void SetupCollection ()
{
collection = new ClaimTypeElementCollection ();
collection.Add (CreateClaimType ("test1", false));
collection.Add (CreateClaimType ("test2", false));
}
[Test]
public void Indexer ()
{
Assert.AreEqual ("test1", collection ["test1"].ClaimType, "#01");
collection ["test3"] = CreateClaimType ("test3", false);
Assert.AreEqual ("test3", collection ["test3"].ClaimType, "#02");
collection ["test2"] = CreateClaimType ("test2", true);
Assert.AreEqual (true, collection ["test2"].IsOptional, "#03");
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void IndexerSetWithIncorrectKey ()
{
collection ["test10"] = CreateClaimType ("test", false);
}
[Test]
public void IndexOf ()
{
Assert.AreEqual (1, collection.IndexOf (CreateClaimType ("test2", false)), "#01");
Assert.AreEqual (-1, collection.IndexOf (CreateClaimType ("test10", false)), "#02");
}
[Test]
public void Remove ()
{
ClaimTypeElement elem = collection ["test2"];
collection.Remove (elem);
Assert.AreEqual (-1, collection.IndexOf (elem), "#01");
collection.Add (elem);
Assert.AreEqual (1, collection.IndexOf (elem), "#02");
collection.RemoveAt (1);
Assert.AreEqual (-1, collection.IndexOf (elem), "#03");
collection.Add (elem);
Assert.AreEqual (1, collection.IndexOf (elem), "#04");
collection.RemoveAt ("test2");
Assert.AreEqual (-1, collection.IndexOf (elem), "#05");
}
[Test]
public void Clear ()
{
ClaimTypeElement elem = collection ["test2"];
collection.Clear ();
Assert.AreEqual (-1, collection.IndexOf (elem), "#01");
Assert.AreEqual (0, collection.Count, "#02");
}
[Test]
public void ContainsKey ()
{
Assert.AreEqual (true, collection.ContainsKey ("test1"), "#01");
Assert.AreEqual (false, collection.ContainsKey ("test10"), "#02");
}
[Test]
public void CopyTo ()
{
ClaimTypeElement[] array = new ClaimTypeElement [4];
collection.CopyTo (array, 2);
Assert.AreEqual ("test1", array [2].ClaimType, "#01");
Assert.AreEqual ("test2", array [3].ClaimType, "#02");
}
}
}

View File

@ -0,0 +1,94 @@
//
// ServiceModelSectionGroupTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.Text;
using System.Xml;
using NUnit.Framework;
using ConfigurationType = System.Configuration.Configuration;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class ServiceModelSectionGroupTest
{
ServiceModelSectionGroup GetConfig (string file)
{
// FIXME: this should work.
//ConfigurationType c = ConfigurationManager.OpenExeConfiguration (file);
//return ServiceModelSectionGroup.GetSectionGroup (c);
return (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (file).GetSectionGroup ("system.serviceModel");
}
[Test]
public void GetSectionGroup ()
{
ServiceModelSectionGroup g = GetConfig ("Test/config/test1");
Assert.IsNotNull (g.Bindings, "bindings");
Assert.IsNotNull (g.Client, "client");
Assert.IsNotNull (g.Services, "services");
Assert.IsNotNull (g.Client.Endpoints, "client/endpoint*");
}
[Test]
[Category ("NotWorking")]
[Ignore ("fails under .NET; I never bothered to fix the test")]
public void BindingCollections () {
ServiceModelSectionGroup g = GetConfig ("Test/config/test1.config");
List<BindingCollectionElement> coll = g.Bindings.BindingCollections;
#if NET_3_5
Assert.AreEqual (20, coll.Count, "Count");
#else
Assert.AreEqual (16, coll.Count, "Count");
#endif
}
[Test]
public void Endpoints ()
{
ServiceModelSectionGroup g = GetConfig ("Test/config/test1");
ChannelEndpointElementCollection col = g.Client.Endpoints;
Assert.AreEqual (1, col.Count, "initial count");
ChannelEndpointElement e = col [0];
Assert.AreEqual (String.Empty, e.Name, "0.Name");
Assert.AreEqual ("IFoo", e.Contract, "0.Contract");
Assert.AreEqual ("basicHttpBinding", e.Binding, "0.Binding");
col.Add (new ChannelEndpointElement ());
Assert.AreEqual (2, col.Count, "after Add()");
}
}
}

View File

@ -0,0 +1,89 @@
//
// StandardBindingCollectionElementTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.ServiceModel.Configuration;
using System.ServiceModel;
using System.Configuration;
using System.Collections.ObjectModel;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class StandardBindingCollectionElementTest
{
class Poker : StandardBindingCollectionElement<BasicHttpBinding, BasicHttpBindingElement>
{
public ConfigurationPropertyCollection GetProperties () {
return Properties;
}
[ConfigurationProperty ("myProperty")]
string MyProperty {
get { return "myProperty"; }
set { }
}
}
[Test]
public void Properties () {
Poker poker = new Poker ();
ConfigurationPropertyCollection coll = poker.GetProperties ();
Assert.AreEqual (1, coll.Count, "Count");
foreach (ConfigurationProperty prop in coll) {
Assert.AreEqual ("", prop.Name);
}
}
[Test]
public void Properties2 () {
Poker p1 = new Poker ();
Poker p2 = new Poker ();
Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
}
[Test]
public void ConfiguredBindings () {
Poker poker = new Poker ();
Assert.AreEqual (0, poker.ConfiguredBindings.Count, "Count #1");
BasicHttpBindingElement elem = new BasicHttpBindingElement ("my_binding");
poker.Bindings.Add (elem);
Assert.AreEqual (1, poker.ConfiguredBindings.Count, "Count #2");
Assert.AreEqual (elem, poker.ConfiguredBindings [0], "Instance");
}
}
}

View File

@ -0,0 +1,94 @@
//
// StandardBindingElementCollectionTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Configuration;
using System.ServiceModel.Configuration;
using System.Text;
using System.ServiceModel.Security;
using System.ServiceModel;
using System.Net.Security;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class StandardBindingElementCollectionTest
{
[Test]
public void BasicHttpBinding () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/basicHttpBinding").GetSectionGroup ("system.serviceModel");
BasicHttpBindingCollectionElement basicHttpBinding = config.Bindings.BasicHttpBinding;
Assert.AreEqual (2, basicHttpBinding.Bindings.Count, "count");
BasicHttpBindingElement binding = basicHttpBinding.Bindings [0];
Assert.AreEqual ("BasicHttpBinding_Service", binding.Name, "Name");
Assert.AreEqual (Encoding.UTF8, binding.TextEncoding, "Name");
Assert.AreEqual (SecurityAlgorithmSuite.Default, binding.Security.Message.AlgorithmSuite, "Name");
}
[Test]
public void NetTcpBinding () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/netTcpBinding").GetSectionGroup ("system.serviceModel");
NetTcpBindingCollectionElement netTcpBinding = config.Bindings.NetTcpBinding;
Assert.AreEqual (1, netTcpBinding.Bindings.Count, "count");
NetTcpBindingElement binding = netTcpBinding.Bindings [0];
Assert.AreEqual ("NetTcpBinding_IHelloWorldService", binding.Name, "Name");
Assert.AreEqual (TransactionProtocol.OleTransactions, binding.TransactionProtocol, "TransactionProtocol");
Assert.AreEqual (SecurityMode.Transport, binding.Security.Mode, "Security.Mode");
Assert.AreEqual (MessageCredentialType.Windows, binding.Security.Message.ClientCredentialType, "Security.Message.ClientCredentialType");
Assert.AreEqual (ProtectionLevel.EncryptAndSign, binding.Security.Transport.ProtectionLevel, "Security.Transport.ProtectionLevel");
Assert.AreEqual (TcpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType, "Security.Transport.ProtectionLevel");
}
[Test]
public void WSHttpBinding () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/wsHttpBinding").GetSectionGroup ("system.serviceModel");
WSHttpBindingCollectionElement wsHttpBinding = config.Bindings.WSHttpBinding;
Assert.AreEqual (1, wsHttpBinding.Bindings.Count, "count");
WSHttpBindingElement binding = wsHttpBinding.Bindings [0];
Assert.AreEqual ("WSHttpBinding_IHelloWorldService", binding.Name, "Name");
Assert.AreEqual (HostNameComparisonMode.StrongWildcard, binding.HostNameComparisonMode, "HostNameComparisonMode");
Assert.AreEqual (SecurityMode.Message, binding.Security.Mode, "Security.Mode");
Assert.AreEqual (MessageCredentialType.Windows, binding.Security.Message.ClientCredentialType, "Security.Message.ClientCredentialType");
Assert.AreEqual (HttpProxyCredentialType.None, binding.Security.Transport.ProxyCredentialType, "Security.Transport.ProtectionLevel");
Assert.AreEqual (HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType, "Security.Transport.ProtectionLevel");
}
[Test]
public void CollectionType () {
StandardBindingElementCollection<BasicHttpBindingElement> coll = new StandardBindingElementCollection<BasicHttpBindingElement> ();
Assert.AreEqual (ConfigurationElementCollectionType.AddRemoveClearMap, coll.CollectionType, "CollectionType");
}
}
}

Some files were not shown because too many files have changed in this diff Show More