File: OidEnumeratorTest.cs

package info (click to toggle)
mono 1.2.2.1-1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 142,720 kB
  • ctags: 256,408
  • sloc: cs: 1,495,736; ansic: 249,442; sh: 18,327; xml: 12,463; makefile: 5,046; perl: 1,248; asm: 635; yacc: 285; sql: 7
file content (82 lines) | stat: -rw-r--r-- 1,799 bytes parent folder | download | duplicates (2)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// OidEnumeratorTest.cs - NUnit tests for OidEnumerator
//
// Author:
//	Sebastien Pouliot (spouliot@motus.com)
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
//

#if NET_2_0

using NUnit.Framework;

using System;
using System.Security.Cryptography;

namespace MonoTests.System.Security.Cryptography {

	[TestFixture]
	public class OidEnumeratorTest : Assertion {

		private OidEnumerator GetEnumerator () 
		{
			OidCollection oc = new OidCollection ();
			oc.Add (new Oid ("1.0"));
			oc.Add (new Oid ("1.1"));
			oc.Add (new Oid ("1.2"));
			return oc.GetEnumerator ();
		}

		[Test]
		[ExpectedException (typeof (ArgumentOutOfRangeException))]
		public void Current_BeforeFirstElement ()
		{
			OidEnumerator enumerator = GetEnumerator ();
			Oid oid = enumerator.Current;
		}

		[Test]
		public void Current () 
		{
			OidEnumerator enumerator = GetEnumerator ();
			enumerator.MoveNext ();
			Oid oid = enumerator.Current;
			AssertNotNull ("Current", oid);
		}

		[Test]
		public void Current_AfterLastElement ()
		{
			OidEnumerator enumerator = GetEnumerator ();
			while (enumerator.MoveNext ());
			Oid oid = enumerator.Current;
			AssertNotNull ("Current_AfterLastElement", oid);
			AssertEquals ("Current==last", "1.2", oid.Value);
		}

		[Test]
		public void MoveNext () 
		{
			OidEnumerator enumerator = GetEnumerator ();
			int n = 0;
			while (enumerator.MoveNext ()) {
				n++;
			}
			AssertEquals ("MoveNext", 3, n);
		}

		[Test]
		[ExpectedException (typeof (ArgumentOutOfRangeException))]
		public void Reset () 
		{
			OidEnumerator enumerator = GetEnumerator ();
			enumerator.MoveNext ();
			AssertNotNull ("Current before reset", enumerator.Current);
			enumerator.Reset ();
			AssertNotNull ("Current after reset", enumerator.Current);
		}
	}
}

#endif