//-----------------------------------------------------------------------
//
// Copyright (c) Andrew Arnott. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Mocks {
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.Extensions;
using DotNetOpenAuth.OpenId.Messages;
internal class MockOpenIdExtension : IOpenIdMessageExtension {
internal const string MockTypeUri = "http://mockextension";
internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
if (typeUri == MockTypeUri) {
return new MockOpenIdExtension();
}
return null;
};
private IDictionary extraData = new Dictionary();
internal MockOpenIdExtension() {
}
///
/// Initializes a new instance of the class.
///
/// The value of the 'Part' parameter.
/// The value of the 'data' parameter.
internal MockOpenIdExtension(string partValue, string extraValue) {
this.Part = partValue;
this.Data = extraValue;
}
#region IOpenIdMessageExtension Members
public string TypeUri {
get { return MockTypeUri; }
}
public IEnumerable AdditionalSupportedTypeUris {
get { return Enumerable.Empty(); }
}
///
/// Gets or sets a value indicating whether this extension was
/// signed by the OpenID Provider.
///
///
/// true if this instance is signed by the provider; otherwise, false.
///
public bool IsSignedByRemoteParty { get; set; }
#endregion
#region IMessage Properties
public Version Version {
get { return new Version(1, 0); }
}
public IDictionary ExtraData {
get { return this.extraData; }
}
#endregion
[MessagePart]
internal string Part { get; set; }
internal string Data {
get {
string data;
this.extraData.TryGetValue("data", out data);
return data;
}
set {
this.extraData["data"] = value;
}
}
public override bool Equals(object obj) {
MockOpenIdExtension other = obj as MockOpenIdExtension;
if (other == null) {
return false;
}
return this.Part.EqualsNullSafe(other.Part) &&
this.Data.EqualsNullSafe(other.Data);
}
public override int GetHashCode() {
return 1; // mock doesn't need a good hash code algorithm
}
#region IMessage methods
public void EnsureValidMessage() {
}
#endregion
}
}