summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Mocks/TestBaseMessage.cs
blob: 49b11bff0c22d29c6a1c82c7ab1d4793174f3f8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//-----------------------------------------------------------------------
// <copyright file="TestBaseMessage.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Test.Mocks {
	using System;
	using System.Collections.Generic;
	using System.Runtime.Serialization;
	using DotNetOpenAuth.Messaging;
	using DotNetOpenAuth.Messaging.Reflection;

	internal interface IBaseMessageExplicitMembers {
		string ExplicitProperty { get; set; }
	}

	internal class TestBaseMessage : IProtocolMessage, IBaseMessageExplicitMembers {
		private Dictionary<string, string> extraData = new Dictionary<string, string>();
		private bool incoming;

		[MessagePart("age", IsRequired = true)]
		public int Age { get; set; }

		[MessagePart]
		public string Name { get; set; }

		[MessagePart("explicit")]
		string IBaseMessageExplicitMembers.ExplicitProperty { get; set; }

		Version IMessage.Version {
			get { return new Version(1, 0); }
		}

		MessageProtections IProtocolMessage.RequiredProtection {
			get { return MessageProtections.None; }
		}

		MessageTransport IProtocolMessage.Transport {
			get { return MessageTransport.Indirect; }
		}

		IDictionary<string, string> IMessage.ExtraData {
			get { return this.extraData; }
		}

		bool IMessage.Incoming {
			get { return this.incoming; }
		}

		internal string PrivatePropertyAccessor {
			get { return this.PrivateProperty; }
			set { this.PrivateProperty = value; }
		}

		[MessagePart("private")]
		private string PrivateProperty { get; set; }

		void IMessage.EnsureValidMessage() { }

		internal void SetAsIncoming() {
			this.incoming = true;
		}
	}
}