1
//-----------------------------------------------------------------------
2 // <copyright file="AttributeExchangeRoundtripTests.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
.Test
.OpenId
.Extensions
{
8 using DotNetOpenAuth
.OpenId
;
9 using DotNetOpenAuth
.OpenId
.Extensions
.AttributeExchange
;
10 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
13 public class AttributeExchangeRoundtripTests
: OpenIdTestBase
{
14 private const string NicknameTypeUri
= WellKnownAttributes
.Name
.Alias
;
15 private const string EmailTypeUri
= WellKnownAttributes
.Contact
.Email
;
16 private const string IncrementingAttribute
= "http://incatt";
17 private int incrementingAttributeValue
= 1;
21 var request
= new FetchRequest();
22 request
.AddAttribute(new AttributeRequest(NicknameTypeUri
));
23 request
.AddAttribute(new AttributeRequest(EmailTypeUri
, false, int.MaxValue
));
25 var response
= new FetchResponse();
26 response
.AddAttribute(new AttributeValues(NicknameTypeUri
, "Andrew"));
27 response
.AddAttribute(new AttributeValues(EmailTypeUri
, "a@a.com", "b@b.com"));
29 ExtensionTestUtilities
.Roundtrip(Protocol
.Default
, new[] { request }
, new[] { response }
);
34 var request
= new StoreRequest();
35 var newAttribute
= new AttributeValues(
36 IncrementingAttribute
,
37 "val" + (incrementingAttributeValue
++).ToString(),
38 "val" + (incrementingAttributeValue
++).ToString());
39 request
.AddAttribute(newAttribute
);
41 var successResponse
= new StoreResponse();
42 successResponse
.Succeeded
= true;
44 ExtensionTestUtilities
.Roundtrip(Protocol
.Default
, new[] { request }
, new[] { successResponse }
);
46 var failureResponse
= new StoreResponse();
47 failureResponse
.Succeeded
= false;
48 failureResponse
.FailureReason
= "Some error";
50 ExtensionTestUtilities
.Roundtrip(Protocol
.Default
, new[] { request }
, new[] { failureResponse }
);