Refactored the entire .config file supporting classes, and added a .config element...
[dotnetoauth.git] / src / DotNetOpenAuth.Test / OpenId / OpenIdTestBase.cs
blob273b15025c252c30d1eabcb5c54c66e4535535ae
1 //-----------------------------------------------------------------------
2 // <copyright file="OpenIdTestBase.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
4 // </copyright>
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth.Test.OpenId {
8 using System;
9 using DotNetOpenAuth.Configuration;
10 using DotNetOpenAuth.Messaging;
11 using DotNetOpenAuth.Messaging.Bindings;
12 using DotNetOpenAuth.OpenId;
13 using DotNetOpenAuth.OpenId.Provider;
14 using DotNetOpenAuth.OpenId.RelyingParty;
15 using DotNetOpenAuth.Test.Mocks;
16 using Microsoft.VisualStudio.TestTools.UnitTesting;
18 public class OpenIdTestBase : TestBase {
19 internal IDirectSslWebRequestHandler RequestHandler;
21 internal MockHttpRequest MockResponder;
23 protected internal static readonly Uri ProviderUri = new Uri("http://provider");
24 protected internal static readonly Uri RPUri = new Uri("http://rp");
25 protected const string IdentifierSelect = "http://specs.openid.net/auth/2.0/identifier_select";
27 protected RelyingPartySecuritySettings RelyingPartySecuritySettings { get; private set; }
29 protected ProviderSecuritySettings ProviderSecuritySettings { get; private set; }
31 [TestInitialize]
32 public override void SetUp() {
33 base.SetUp();
35 this.RelyingPartySecuritySettings = DotNetOpenAuthSection.Configuration.OpenId.RelyingParty.SecuritySettings.CreateSecuritySettings();
36 this.ProviderSecuritySettings = DotNetOpenAuthSection.Configuration.OpenId.Provider.SecuritySettings.CreateSecuritySettings();
38 this.MockResponder = MockHttpRequest.CreateUntrustedMockHttpHandler();
39 this.RequestHandler = this.MockResponder.MockWebRequestHandler;
42 protected Identifier GetMockIdentifier(TestSupport.Scenarios scenario, ProtocolVersion providerVersion) {
43 return this.GetMockIdentifier(scenario, providerVersion, false);
46 protected Identifier GetMockIdentifier(TestSupport.Scenarios scenario, ProtocolVersion providerVersion, bool useSsl) {
47 return TestSupport.GetMockIdentifier(scenario, this.MockResponder, providerVersion, useSsl);
50 /// <summary>
51 /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
52 /// </summary>
53 /// <returns>The new instance.</returns>
54 protected OpenIdRelyingParty CreateRelyingParty() {
55 var rp = new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore());
56 rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
57 return rp;
60 /// <summary>
61 /// Creates a standard <see cref="OpenIdProvider"/> instance for general testing.
62 /// </summary>
63 /// <returns>The new instance.</returns>
64 protected OpenIdProvider CreateProvider() {
65 var op = new OpenIdProvider(new StandardProviderApplicationStore());
66 op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
67 return op;