summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs
blob: 321deedb80992c200d585fe48b4394e997d8d6d0 (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
//-----------------------------------------------------------------------
// <copyright file="PositiveAuthenticationResponseSnapshotTests.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
	using System.Collections.Generic;
	using System.IO;
	using System.Runtime.Serialization;
	using System.Runtime.Serialization.Formatters.Binary;
	using DotNetOpenAuth.OpenId;
	using DotNetOpenAuth.OpenId.Messages;
	using DotNetOpenAuth.OpenId.RelyingParty;
	using Moq;
	using NUnit.Framework;

	[TestFixture]
	public class PositiveAuthenticationResponseSnapshotTests : OpenIdTestBase {
		/// <summary>
		/// Verifies that the PositiveAuthenticationResponseSnapshot is serializable,
		/// as required by the <see cref="OpenIdRelyingPartyAjaxControlBase"/> class.
		/// </summary>
		[Test]
		public void Serializable() {
			var response = new Mock<IAuthenticationResponse>(MockBehavior.Strict);
			response.Setup(o => o.ClaimedIdentifier).Returns(VanityUri);
			response.Setup(o => o.FriendlyIdentifierForDisplay).Returns(VanityUri.AbsoluteUri);
			response.Setup(o => o.Status).Returns(AuthenticationStatus.Authenticated);
			response.Setup(o => o.Provider).Returns(new ProviderEndpointDescription(OPUri, Protocol.Default.Version));
			response.Setup(o => o.GetUntrustedCallbackArguments()).Returns(new Dictionary<string, string>());
			response.Setup(o => o.GetCallbackArguments()).Returns(new Dictionary<string, string>());
			var snapshot = new PositiveAuthenticationResponseSnapshot(response.Object);
			MemoryStream ms = new MemoryStream();
			IFormatter formatter = new BinaryFormatter();
			formatter.Serialize(ms, snapshot);
		}
	}
}