diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test')
4 files changed, 80 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index bda7a71..75aec44 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -131,6 +131,7 @@ <Compile Include="OpenId\OpenIdCoordinator.cs" /> <Compile Include="OpenId\AssociationHandshakeTests.cs" /> <Compile Include="OpenId\OpenIdTestBase.cs" /> + <Compile Include="OpenId\Provider\OpenIdProviderTests.cs" /> <Compile Include="OpenId\RealmTests.cs" /> <Compile Include="OpenId\RelyingParty\AuthenticationRequestTests.cs" /> <Compile Include="OpenId\RelyingParty\FailedAuthenticationResponseTests.cs" /> diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs index a946856..e007343 100644 --- a/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs @@ -59,7 +59,7 @@ namespace DotNetOpenAuth.Test.OpenId { } if (this.Provider == null) { - this.Provider = new OpenIdProvider(new AssociationMemoryStore<AssociationRelyingPartyType>(), new NonceMemoryStore(TimeSpan.FromHours(3))); + this.Provider = new OpenIdProvider(new StandardProviderApplicationStore(TimeSpan.FromHours(3))); } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs index 5fa98a1..13079a7 100644 --- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs @@ -56,5 +56,15 @@ namespace DotNetOpenAuth.Test.OpenId { rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler; return rp; } + + /// <summary> + /// Creates a standard <see cref="OpenIdProvider"/> instance for general testing. + /// </summary> + /// <returns>The new instance.</returns> + protected OpenIdProvider CreateProvider() { + var op = new OpenIdProvider(new StandardProviderApplicationStore(TimeSpan.FromMinutes(5))); + op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler; + return op; + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs new file mode 100644 index 0000000..65fe99e --- /dev/null +++ b/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs @@ -0,0 +1,68 @@ +//----------------------------------------------------------------------- +// <copyright file="OpenIdProviderTests.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test.OpenId.Provider { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using DotNetOpenAuth.OpenId.Provider; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class OpenIdProviderTests : OpenIdTestBase { + private OpenIdProvider provider; + + [TestInitialize] + public override void SetUp() { + base.SetUp(); + + this.provider = this.CreateProvider(); + } + + /// <summary> + /// Verifies that the constructor throws an exception if the app store is null. + /// </summary> + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void CtorNull() { + new OpenIdProvider(null); + } + + /// <summary> + /// Verifies that the SecuritySettings property throws when set to null. + /// </summary> + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void SecuritySettingsSetNull() { + this.provider.SecuritySettings = null; + } + + /// <summary> + /// Verifies the SecuritySettings property can be set to a new instance. + /// </summary> + [TestMethod] + public void SecuritySettings() { + var newSettings = new ProviderSecuritySettings(); + this.provider.SecuritySettings = newSettings; + Assert.AreSame(newSettings, this.provider.SecuritySettings); + } + + /// <summary> + /// Verifies the Channel property. + /// </summary> + [TestMethod] + public void ChannelGetter() { + Assert.IsNotNull(this.provider.Channel); + } + + /// <summary> + /// Verifies the GetRequest method throws outside an HttpContext. + /// </summary> + [TestMethod, ExpectedException(typeof(InvalidOperationException))] + public void GetRequestNoContext() { + this.provider.GetRequest(); + } + } +} |