summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId.Test/Extensions/AttributeRequestTests.cs
blob: bf8e9d4f1e29df7b1de51a44e3ce759eb5b60ced (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DotNetOpenId.Extensions.AttributeExchange;

namespace DotNetOpenId.Test.Extensions {
	[TestFixture]
	public class AttributeRequestTests {
		[Test]
		public void CtorDefault() {
			AttributeRequest req = new AttributeRequest();
			Assert.AreEqual(1, req.Count);
			Assert.IsNull(req.TypeUri);
			Assert.IsFalse(req.IsRequired);
		}

		[Test, ExpectedException(typeof(ArgumentNullException))]
		public void CtorEmptyTypeUri() {
			new AttributeRequest(string.Empty);
		}

		[Test, ExpectedException(typeof(ArgumentNullException))]
		public void CtorNullTypeUri() {
			new AttributeRequest(null);
		}

		[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
		public void CtorCountZero() {
			new AttributeRequest(WellKnownAttributes.Contact.Email, false, 0);
		}

		[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
		public void CtorCountNegative() {
			new AttributeRequest(WellKnownAttributes.Contact.Email, false, -1);
		}

		[Test]
		public void CtorFull() {
			var req = new AttributeRequest(WellKnownAttributes.Contact.Email, true, 5);
			Assert.AreEqual(WellKnownAttributes.Contact.Email, req.TypeUri);
			Assert.IsTrue(req.IsRequired);
			Assert.AreEqual(5, req.Count);
		}

		[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
		public void SetCountZero() {
			var req = new AttributeRequest();
			req.Count = 0;
		}

		[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
		public void SetCountNegative() {
			var req = new AttributeRequest();
			req.Count = -1;
		}
	}
}