summaryrefslogtreecommitdiff
path: root/mcs/class/System/Test/System.Security.Cryptography.X509Certificates/X509Certificate2CollectionTest.cs
blob: e8ef4d15ad0204870062f30ecfff9dd10ea70bb3 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
//
// X509CertificateCollection2Test.cs 
//	- NUnit tests for X509CertificateCollection2
//
// Authors:
//	Sebastien Pouliot  <sebastien@ximian.com>
//	David Ferguson  <davecferguson@gmail.com>
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#if NET_2_0

using NUnit.Framework;

using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace MonoTests.System.Security.Cryptography.X509Certificates {

	[TestFixture]
	public class X509Certificate2CollectionTest {

		private X509Certificate2Collection empty;
		private X509Certificate2Collection single;
		private X509Certificate2Collection collection;

		private X509Certificate2 cert_empty;
		private X509Certificate2 cert1;
		private X509Certificate2 cert2;

		[TestFixtureSetUp]
		public void FixtureSetUp ()
		{
			cert_empty = new X509Certificate2 ();
			cert1 = new X509Certificate2 (X509Certificate2Test.farscape_pfx, "farscape", X509KeyStorageFlags.Exportable);
			cert2 = new X509Certificate2 (Encoding.ASCII.GetBytes (X509Certificate2Test.base64_cert));

			empty = new X509Certificate2Collection ();
			single = new X509Certificate2Collection ();
			single.Add (cert1);
			collection = new X509Certificate2Collection (single);
			collection.Add (cert2);
		}

		[Test]
		public void Ctor ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			Assert.AreEqual (0, c.Count, "Count");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Ctor_X509CertificateCollection2_Null ()
		{
			new X509Certificate2Collection ((X509Certificate2Collection) null);
		}

		[Test]
		public void Ctor_X509CertificateCollection2_Empty ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection (empty);
			Assert.AreEqual (0, c.Count, "Count");
		}

		[Test]
		public void Ctor_X509CertificateCollection2 ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection (collection);
			Assert.AreEqual (2, c.Count, "Count");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Ctor_X509Certificate2_Null ()
		{
			new X509Certificate2Collection ((X509Certificate2) null);
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Ctor_X509Certificate2Array_Null ()
		{
			new X509Certificate2Collection ((X509Certificate2[]) null);
		}

		[Test]
		public void Ctor_X509Certificate2Array_Empty ()
		{
			X509Certificate2[] array = new X509Certificate2 [0];
			X509Certificate2Collection c = new X509Certificate2Collection (array);
			Assert.AreEqual (0, c.Count, "Count");
		}

		[Test]
		public void Ctor_X509Certificate2Array ()
		{
			X509Certificate2[] array = new X509Certificate2[3] { cert1, cert2, cert_empty };
			X509Certificate2Collection c = new X509Certificate2Collection (array);
			Assert.AreEqual (3, c.Count, "Count");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Add_X509Certificate2_Null ()
		{
			collection.Add ((X509Certificate2) null);
		}

		[Test]
		public void Add_X509Certificate2 ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			Assert.AreEqual (0, c.Count, "0");
			c.Add (cert1);
			Assert.AreEqual (1, c.Count, "1");
			// adding invalid certificate
			c.Add (cert_empty);
			Assert.AreEqual (2, c.Count, "2");
			// re-adding same certificate
			c.Add (cert1);
			Assert.AreEqual (3, c.Count, "3");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void AddRange_X509Certificate2Collection_Null ()
		{
			collection.AddRange ((X509Certificate2Collection) null);
		}

		[Test]
		public void AddRange_X509Certificate2Collection ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			c.AddRange (empty);
			Assert.AreEqual (0, c.Count, "0");
			c.AddRange (single);
			Assert.AreEqual (1, c.Count, "1");
			c.AddRange (collection);
			Assert.AreEqual (3, c.Count, "3");
			// re-adding same collection
			c.AddRange (single);
			Assert.AreEqual (4, c.Count, "4");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void AddRange_X509Certificate2Array_Null ()
		{
			collection.AddRange ((X509Certificate2[]) null);
		}

		[Test]
		public void AddRange_X509Certificate2Array ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			c.AddRange (new X509Certificate2 [0]);
			Assert.AreEqual (0, c.Count, "0");
			c.AddRange (new X509Certificate2[3] { cert1, cert2, cert_empty });
			Assert.AreEqual (3, c.Count, "3");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Contains_X509Certificate2_Null ()
		{
			empty.Contains ((X509Certificate2) null);
		}

		[Test]
		public void Contains_Empty ()
		{
			Assert.IsFalse (empty.Contains (cert_empty), "empty|cert_empty");
			Assert.IsFalse (empty.Contains (cert1), "empty|cert1");
			Assert.IsFalse (empty.Contains (cert2), "empty|cert2");
		}

		[Test]
		public void Contains ()
		{
			Assert.IsTrue (single.Contains (cert1), "single|cert1");
			Assert.IsFalse (single.Contains (cert2), "single|cert2");

			Assert.IsTrue (collection.Contains (cert1), "multi|cert1");
			Assert.IsTrue (collection.Contains (cert2), "multi|cert2");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Contains_EmptyCert ()
		{
			single.Contains (cert_empty);
			// note: Equals fails, but it works for an empty collection (not called)
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Empty_Authenticode ()
		{
			empty.Export (X509ContentType.Authenticode);
		}

		[Test]
		public void Export_Empty ()
		{
			Assert.IsNull (empty.Export (X509ContentType.Cert), "Cert");
			Assert.IsNull (empty.Export (X509ContentType.Cert, null), "Cert,null");
			Assert.IsNull (empty.Export (X509ContentType.Cert, String.Empty), "Cert,Empty");
			Assert.IsNull (empty.Export (X509ContentType.SerializedCert), "SerializedCert");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Empty_Pfx ()
		{
			byte[] data = empty.Export (X509ContentType.Pfx);
			Assert.IsNotNull (data, "data");
			Assert.AreEqual (X509ContentType.Pfx, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Empty_Pkcs12 ()
		{
			byte[] data = empty.Export (X509ContentType.Pkcs12);
			Assert.IsNotNull (data, "data");
			Assert.AreEqual (X509ContentType.Pkcs12, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Empty_Pkcs7 ()
		{
			byte[] data = empty.Export (X509ContentType.Pkcs7);
			Assert.IsNotNull (data, "data");
			Assert.AreEqual (X509ContentType.Pkcs7, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Empty_SerializedStore ()
		{
			byte[] data = empty.Export (X509ContentType.SerializedStore);
			Assert.IsNotNull (data, "data");
			Assert.AreEqual (X509ContentType.SerializedStore, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Empty_Unknown ()
		{
			empty.Export (X509ContentType.Unknown);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Empty_Bad ()
		{
			empty.Export ((X509ContentType)Int32.MinValue);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Single_Authenticode ()
		{
			single.Export (X509ContentType.Authenticode);
		}

		[Test]
		public void Export_Single_Cert ()
		{
			byte[] data = single.Export (X509ContentType.Cert);
			Assert.AreEqual (X509ContentType.Cert, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			Assert.AreEqual (data, cert1.RawData, "RawData");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Single_Pfx ()
		{
			byte[] data = single.Export (X509ContentType.Pfx);
			Assert.AreEqual (X509ContentType.Pfx, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Single_Pkcs12 ()
		{
			byte[] data = single.Export (X509ContentType.Pkcs12);
			Assert.AreEqual (X509ContentType.Pkcs12, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Single_Pkcs7 ()
		{
			byte[] data = single.Export (X509ContentType.Pkcs7);
			Assert.AreEqual (X509ContentType.Pkcs7, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Single_SerializedCert ()
		{
			byte[] data = single.Export (X509ContentType.SerializedCert);
			Assert.AreEqual (X509ContentType.SerializedCert, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Single_SerializedStore ()
		{
			byte[] data = single.Export (X509ContentType.SerializedStore);
			Assert.AreEqual (X509ContentType.SerializedStore, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Single_Unknown ()
		{
			single.Export (X509ContentType.Unknown);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Single_Bad ()
		{
			single.Export ((X509ContentType) Int32.MinValue);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Multiple_Authenticode ()
		{
			collection.Export (X509ContentType.Authenticode);
		}

		[Test]
		public void Export_Multiple_Cert ()
		{
			byte[] data = collection.Export (X509ContentType.Cert);
			Assert.AreEqual (X509ContentType.Cert, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// last certificate was exported
			Assert.AreEqual (data, cert2.RawData, "RawData");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert2, c, "Equals");
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Multiple_Pfx ()
		{
			byte[] data = collection.Export (X509ContentType.Pfx);
			Assert.AreEqual (X509ContentType.Pfx, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Multiple_Pkcs12 ()
		{
			byte[] data = collection.Export (X509ContentType.Pkcs12);
			Assert.AreEqual (X509ContentType.Pkcs12, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			Assert.AreEqual (cert1, c, "Equals");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Multiple_Pkcs7 ()
		{
			byte[] data = collection.Export (X509ContentType.Pkcs7);
			Assert.AreEqual (X509ContentType.Pkcs7, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[Category ("NotWorking")]
		public void Export_Multiple_SerializedCert ()
		{
			byte[] data = collection.Export (X509ContentType.SerializedCert);
			Assert.AreEqual (X509ContentType.SerializedCert, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// usable
			X509Certificate2 c = new X509Certificate2 (data);
			// last certificate was exported
			Assert.AreEqual (cert2, c, "Equals");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		[Category ("NotWorking")]
		public void Export_Multiple_SerializedStore ()
		{
			byte[] data = collection.Export (X509ContentType.SerializedStore);
			Assert.AreEqual (X509ContentType.SerializedStore, X509Certificate2.GetCertContentType (data), "GetCertContentType");
			// not usable
			new X509Certificate2 (data);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Multiple_Unknown ()
		{
			collection.Export (X509ContentType.Unknown);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Export_Multiple_Bad ()
		{
			collection.Export ((X509ContentType) Int32.MinValue);
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Find_FindValue_Null ()
		{
			empty.Find (X509FindType.FindByApplicationPolicy, null, true);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindType_Bad ()
		{
			empty.Find ((X509FindType)Int32.MinValue, new object(), true);
		}

		[Test]
		public void Find_Empty ()
		{
			string oid = "1.2.3.4";
			Assert.AreEqual (0, empty.Find (X509FindType.FindByApplicationPolicy, oid, false).Count, "Empty|FindByApplicationPolicy");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByCertificatePolicy, oid, false).Count, "Empty|FindByCertificatePolicy");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByExtension, oid, false).Count, "Empty|FindByExtension");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByIssuerDistinguishedName, String.Empty, false).Count, "Empty|FindByIssuerDistinguishedName");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByIssuerName, String.Empty, false).Count, "Empty|FindByIssuerName");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.CrlSign, false).Count, "Empty|FindByKeyUsage");
			Assert.AreEqual (0, empty.Find (X509FindType.FindBySerialNumber, String.Empty, false).Count, "Empty|FindBySerialNumber");
			Assert.AreEqual (0, empty.Find (X509FindType.FindBySubjectDistinguishedName, String.Empty, false).Count, "Empty|FindBySubjectDistinguishedName");
			Assert.AreEqual (0, empty.Find (X509FindType.FindBySubjectKeyIdentifier, String.Empty, false).Count, "Empty|FindBySubjectKeyIdentifier");
			Assert.AreEqual (0, empty.Find (X509FindType.FindBySubjectName, String.Empty, false).Count, "Empty|FindByTemplateName");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByTemplateName, String.Empty, false).Count, "Empty|FindByTemplateName");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByThumbprint, String.Empty, false).Count, "Empty|FindByThumbprint");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByTimeExpired, DateTime.Now, false).Count, "Empty|FindByTimeExpired");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByTimeNotYetValid, DateTime.Now, false).Count, "Empty|FindByTimeNotYetValid");
			Assert.AreEqual (0, empty.Find (X509FindType.FindByTimeValid, DateTime.Now, false).Count, "Empty|FindByTimeValid");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_CollectionWithEmptyCert ()
		{
			new X509Certificate2Collection (cert_empty).Find (X509FindType.FindByIssuerName, String.Empty, false);
		}

		[Test]
		public void Find_FindByApplicationPolicy ()
		{
			X509Certificate2Collection result = collection.Find (X509FindType.FindByApplicationPolicy, "1.2.3.4", false);
			Assert.AreEqual (1, result.Count, "FindByApplicationPolicy/Empty/false");
			Assert.AreEqual (0, result[0].Extensions.Count, "no extension");
			// FIXME - need a negative test case (with extensions)
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void Find_FindByApplicationPolicy_NotOid ()
		{
			collection.Find (X509FindType.FindByApplicationPolicy, "policy", false);
		}

		[Test]
		public void Find_FindByCertificatePolicy ()
		{
			Assert.AreEqual (0, collection.Find (X509FindType.FindByCertificatePolicy, "1.2.3.4", false).Count, "FindByApplicationPolicy/Empty/false");
			// FIXME - need a positive test case
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void Find_FindByCertificatePolicy_NotOid ()
		{
			collection.Find (X509FindType.FindByCertificatePolicy, "policy", false);
		}

		[Test]
		public void Find_FindByExtension ()
		{
			// partial match
			Assert.AreEqual (0, collection.Find (X509FindType.FindByExtension, "2.5.29", false).Count, "FindByExtension/2.5.29/false");
			// full match
			Assert.AreEqual (1, collection.Find (X509FindType.FindByExtension, "2.5.29.1", false).Count, "FindByExtension/2.5.29.1/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByExtension, "2.5.29.37", false).Count, "FindByExtension/2.5.29.37/false");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void Find_FindByExtension_NotOid ()
		{
			collection.Find (X509FindType.FindByExtension, "KeyUsage", false);
		}

		[Test]
		public void Find_FindByIssuerDistinguishedName ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerDistinguishedName, String.Empty, false).Count, "FindByIssuerDistinguishedName/Empty/false");
			// partial match
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerDistinguishedName, "Mono", false).Count, "FindByIssuerDistinguishedName/Mono/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerDistinguishedName, "CASTOR\\poupou", false).Count, "FindByIssuerDistinguishedName/castor/false");
			// full match (requires CN= parts)
			Assert.AreEqual (1, collection.Find (X509FindType.FindByIssuerDistinguishedName, cert1.Issuer, false).Count, "FindByIssuerDistinguishedName/cert1/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByIssuerDistinguishedName, cert2.IssuerName.Name, false).Count, "FindByIssuerDistinguishedName/cert2/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByIssuerDistinguishedName_NotString ()
		{
			collection.Find (X509FindType.FindByIssuerDistinguishedName, 1, false);
		}

		[Test]
		public void Find_FindByIssuerName ()
		{
			// empty
			Assert.AreEqual (collection.Count, collection.Find (X509FindType.FindByIssuerName, String.Empty, false).Count, "FindByIssuerName/Empty/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerName, String.Empty, true).Count, "FindByIssuerName/Empty/true");
			// partial match
			Assert.AreEqual (1, collection.Find (X509FindType.FindByIssuerName, "Mono", false).Count, "FindByIssuerName/Mono/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByIssuerName, "CASTOR\\poupou", false).Count, "FindByIssuerName/castor/false");
			// full match (doesn't like CN= parts)
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerName, cert1.Issuer, false).Count, "FindByIssuerName/cert1/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByIssuerName, cert2.IssuerName.Name, false).Count, "FindByIssuerName/cert2/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByIssuerName_NotString ()
		{
			collection.Find (X509FindType.FindByIssuerName, DateTime.Now, false);
		}

		[Test]
		public void Find_FindByKeyUsage ()
		{
			// empty
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.None, false).Count, "FindByKeyUsage/None/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.None, true).Count, "FindByKeyUsage/None/true");
			// always match if no KeyUsageExtension is present in certificate, EnhancedKeyUsageExtension not considered
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.CrlSign, false).Count, "FindByKeyUsage/CrlSign/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.DataEncipherment, false).Count, "FindByKeyUsage/DataEncipherment/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.DecipherOnly, false).Count, "FindByKeyUsage/DecipherOnly/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.DigitalSignature, false).Count, "FindByKeyUsage/DigitalSignature/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.EncipherOnly, false).Count, "FindByKeyUsage/EncipherOnly/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.KeyAgreement, false).Count, "FindByKeyUsage/KeyAgreement/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.KeyCertSign, false).Count, "FindByKeyUsage/KeyCertSign/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.KeyEncipherment, false).Count, "FindByKeyUsage/KeyEncipherment/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByKeyUsage, X509KeyUsageFlags.NonRepudiation, false).Count, "FindByKeyUsage/NonRepudiation/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByIssuerName_NotX509KeyUsageFlags ()
		{
			collection.Find (X509FindType.FindByKeyUsage, String.Empty, false);
		}

		[Test]
		public void Find_FindBySerialNumber ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySerialNumber, String.Empty, false).Count, "FindBySerialNumber/Empty/false");
			// partial match (start, end)
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySerialNumber, "748B", false).Count, "FindBySerialNumber/748B/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySerialNumber, "4769", false).Count, "FindBySerialNumber/4769/false");
			// full match
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert1.SerialNumber, false).Count, "FindBySerialNumber/cert1/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert2.SerialNumber, false).Count, "FindBySerialNumber/cert2/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert1.SerialNumber.ToLowerInvariant (), false).Count, "FindBySerialNumber/cert1b/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert2.SerialNumber.ToLowerInvariant (), false).Count, "FindBySerialNumber/cert2b/false");
			// full match inverted
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert1.GetSerialNumberString (), false).Count, "FindBySerialNumber/cert1c/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert2.GetSerialNumberString (), false).Count, "FindBySerialNumber/cert2c/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert1.GetSerialNumberString ().ToLowerInvariant (), false).Count, "FindBySerialNumber/cert1d/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySerialNumber, cert2.GetSerialNumberString ().ToLowerInvariant (), false).Count, "FindBySerialNumber/cert2d/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindBySerialNumber_NotString ()
		{
			collection.Find (X509FindType.FindBySerialNumber, DateTime.Now, false);
		}

		[Test]
		public void Find_FindBySubjectDistinguishedName ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectDistinguishedName, String.Empty, false).Count, "FindBySubjectDistinguishedName/Empty/false");
			// partial match
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectDistinguishedName, "Mono", false).Count, "FindBySubjectDistinguishedName/Mono/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectDistinguishedName, "CASTOR\\poupou", false).Count, "FindBySubjectDistinguishedName/castor/false");
			// full match (requires CN= parts) using all lowercase
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySubjectDistinguishedName, cert1.Subject.ToLowerInvariant (), false).Count, "FindBySubjectDistinguishedName/cert1/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySubjectDistinguishedName, cert2.SubjectName.Name.ToLowerInvariant (), false).Count, "FindBySubjectDistinguishedName/cert2/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindBySubjectDistinguishedName_NotString ()
		{
			collection.Find (X509FindType.FindBySubjectDistinguishedName, new object (), false);
		}

		[Test]
		public void Find_FindBySubjectKeyIdentifier ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectKeyIdentifier, String.Empty, false).Count, "FindBySubjectKeyIdentifier/Empty/false");

			X509Certificate2Collection c = new X509Certificate2Collection (collection);
			c.Add (new X509Certificate2 (X509Certificate2Test.cert_8));
			Assert.AreEqual (0, c.Find (X509FindType.FindBySubjectKeyIdentifier, "9D2D73C3B8E34D2928C3", false).Count, "FindBySubjectKeyIdentifier/half/false");
			Assert.AreEqual (1, c.Find (X509FindType.FindBySubjectKeyIdentifier, "9D2D73C3B8E34D2928C365BEA998CBD68A06689C", false).Count, "FindBySubjectKeyIdentifier/full/false");
			Assert.AreEqual (1, c.Find (X509FindType.FindBySubjectKeyIdentifier, "9d2d73c3b8e34d2928c365bea998cbd68a06689c", false).Count, "FindBySubjectKeyIdentifier/full/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindBySubjectKeyIdentifier_NotString ()
		{
			collection.Find (X509FindType.FindBySubjectKeyIdentifier, 1, false);
		}

		[Test]
		public void Find_FindBySubjectName ()
		{
			// empty
			Assert.AreEqual (collection.Count, collection.Find (X509FindType.FindBySubjectName, String.Empty, false).Count, "FindBySubjectName/Empty/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectName, String.Empty, true).Count, "FindBySubjectName/Empty/true");
			// partial match (using inverted case)
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySubjectName, "farscap", false).Count, "FindBySubjectName/Mono/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindBySubjectName, "castor\\POUPOU", false).Count, "FindBySubjectName/castor/false");
			// full match (doesn't like CN= parts)
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectName, cert1.Subject, false).Count, "FindBySubjectName/cert1/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindBySubjectName, cert2.SubjectName.Name, false).Count, "FindBySubjectName/cert2/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindBySubjectName_NotString ()
		{
			collection.Find (X509FindType.FindBySubjectName, 'c', false);
		}

		[Test]
		public void Find_FindByTemplateName ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTemplateName, String.Empty, false).Count, "FindByTemplateName/Empty/false");
			// wilcard match
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTemplateName, "*", false).Count, "FindByTemplateName/Mono/false");
			// FIXME - need a positive test case
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByTemplateName_NotString ()
		{
			collection.Find (X509FindType.FindByTemplateName, 0, false);
		}

		[Test]
		public void Find_FindByThumbprint ()
		{
			// empty
			Assert.AreEqual (0, collection.Find (X509FindType.FindByThumbprint, String.Empty, false).Count, "FindByThumbprint/Empty/false");
			// partial match (start, end)
			Assert.AreEqual (0, collection.Find (X509FindType.FindByThumbprint, "3029", false).Count, "FindByThumbprint/3029/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByThumbprint, "8529", false).Count, "FindByThumbprint/8529/false");
			// full match
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert1.Thumbprint, false).Count, "FindByThumbprint/cert1/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert2.Thumbprint, false).Count, "FindByThumbprint/cert2/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert1.Thumbprint.ToLowerInvariant (), false).Count, "FindByThumbprint/cert1b/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert2.Thumbprint.ToLowerInvariant (), false).Count, "FindByThumbprint/cert2b/false");
			// full match inverted
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert1.GetCertHashString (), false).Count, "FindByThumbprint/cert1c/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert2.GetCertHashString (), false).Count, "FindByThumbprint/cert2c/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert1.GetCertHashString ().ToLowerInvariant (), false).Count, "FindByThumbprint/cert1d/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByThumbprint, cert2.GetCertHashString ().ToLowerInvariant (), false).Count, "FindByThumbprint/cert2d/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByThumbprint_NotString ()
		{
			collection.Find (X509FindType.FindByThumbprint, 0, false);
		}

		[Test]
		public void Find_FindByTimeExpired ()
		{
			// now (valid from today until 2039)
			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeExpired, DateTime.Now, false).Count, "FindByTimeExpired/Now/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeExpired, new DateTime (631108726620000000), false).Count, "FindByTimeExpired/2000/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByTimeExpired, new DateTime (644392619990000000), false).Count, "FindByTimeExpired/2042/false");

			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeExpired, cert1.NotAfter, false).Count, "FindByTimeExpired/cert1.NotAfter/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeExpired, cert1.NotBefore, false).Count, "FindByTimeExpired/cert1.NotBefore/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeExpired, cert2.NotAfter, false).Count, "FindByTimeExpired/cert2.NotAfter/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeExpired, cert2.NotBefore, false).Count, "FindByTimeExpired/cert2.NotBefore/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByTimeExpired_NotDateTime ()
		{
			collection.Find (X509FindType.FindByTimeExpired, String.Empty, false);
		}

		[Test]
		public void Find_FindByTimeNotYetValid ()
		{
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeNotYetValid, DateTime.Now, false).Count, "FindByTimeNotYetValid/Now/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByTimeNotYetValid, new DateTime (631108726620000000), false).Count, "FindByTimeNotYetValid/2000/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeNotYetValid, new DateTime (644392619990000000), false).Count, "FindByTimeNotYetValid/2042/false");

			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeNotYetValid, cert1.NotAfter, false).Count, "FindByTimeNotYetValid/cert1.NotAfter/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeNotYetValid, cert1.NotBefore, false).Count, "FindByTimeNotYetValid/cert1.NotBefore/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeNotYetValid, cert2.NotAfter, false).Count, "FindByTimeNotYetValid/cert2.NotAfter/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeNotYetValid, cert2.NotBefore, false).Count, "FindByTimeNotYetValid/cert2.NotBefore/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByTimeNotYetValid_NotDateTime ()
		{
			collection.Find (X509FindType.FindByTimeNotYetValid, DateTime.Now.ToString (), false);
		}

		[Test]
		public void Find_FindByTimeValid ()
		{
			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeValid, DateTime.Now, false).Count, "FindByTimeValid/Now/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeValid, new DateTime (631108726620000000), false).Count, "FindByTimeValid/2000/false");
			Assert.AreEqual (0, collection.Find (X509FindType.FindByTimeValid, new DateTime (644392619990000000), false).Count, "FindByTimeValid/2042/false");

			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeValid, cert1.NotAfter, false).Count, "FindByTimeValid/cert1.NotAfter/false");
			Assert.AreEqual (1, collection.Find (X509FindType.FindByTimeValid, cert1.NotBefore, false).Count, "FindByTimeValid/cert1.NotBefore/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByTimeValid, cert2.NotAfter, false).Count, "FindByTimeValid/cert2.NotAfter/false");
			Assert.AreEqual (2, collection.Find (X509FindType.FindByTimeValid, cert2.NotBefore, false).Count, "FindByTimeValid/cert2.NotBefore/false");
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Find_FindByTimeValid_NotDateTime ()
		{
			collection.Find (X509FindType.FindByTimeValid, String.Empty, false);
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Remove_X509Certificate2_Null ()
		{
			collection.Remove ((X509Certificate2) null);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void Remove_X509Certificate2_Empty ()
		{
			single.Remove (cert_empty);
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void RemoveRange_X509Certificate2Collection_Null ()
		{
			collection.RemoveRange ((X509Certificate2Collection) null);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void RemoveRange_X509Certificate2Collection_EmptyCert ()
		{
			collection.RemoveRange (new X509Certificate2Collection (cert_empty));
		}

		[Test]
		public void RemoveRange_X509Certificate2Collection_Empty ()
		{
			Assert.AreEqual (2, collection.Count, "Count/before");
			collection.RemoveRange (empty);
			Assert.AreEqual (2, collection.Count, "Count/after");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void RemoveRange_X509Certificate2Array_Null ()
		{
			collection.RemoveRange ((X509Certificate2[]) null);
		}

		[Test]
		[ExpectedException (typeof (CryptographicException))]
		public void RemoveRange_X509Certificate2Array_EmptyCert ()
		{
			collection.RemoveRange (new X509Certificate2[1] { cert_empty });
		}

		[Test]
		public void RemoveRange_X509Certificate2Array_Empty ()
		{
			Assert.AreEqual (2, collection.Count, "Count/before");
			collection.RemoveRange (new X509Certificate2[0]);
			Assert.AreEqual (2, collection.Count, "Count/after");
		}

		[Test]
		[ExpectedException (typeof (InvalidCastException))]
		public void MixedCollection_Indexer ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			c.Add (new X509Certificate (X509Certificate2Test.farscape_pfx, "farscape"));
			Assert.IsTrue ((c[0] is X509Certificate), "X509Certificate/0");
			// it's impossible to use the this[int] indexer to get the object in the collection
		}

		[Test]
		[ExpectedException (typeof (InvalidCastException))]
		public void MixedCollection_Enumerator ()
		{
			X509Certificate2Collection c = new X509Certificate2Collection ();
			c.Add (new X509Certificate (X509Certificate2Test.farscape_pfx, "farscape"));
			foreach (object o in c) {
				Assert.IsTrue ((o is X509Certificate), "X509Certificate");
			}
		}

		[Test]
		public void X509Certificate2CollectionFindBySubjectName_Test ()
		{
			// Created with mono makecert
			// makecert -n "O=Root, CN=MyCNName, T=SomeElse" -r <filename>
			const string Cert = "MIIB6zCCAVSgAwIBAgIQEshQw4bf1kSsYsUoLCjlpTANBgkqhkiG9w0BAQUFADA1MQ0wCwYDVQQKEwRSb290MREwDwYDVQQDEwhNeUNOTmFtZTERMA8GA1UEDBMIU29tZUVsc2UwHhcNMTIwMzE1MTUzNjE0WhcNMzkxMjMxMjM1OTU5WjA1MQ0wCwYDVQQKEwRSb290MREwDwYDVQQDEwhNeUNOTmFtZTERMA8GA1UEDBMIU29tZUVsc2UwgZ0wDQYJKoZIhvcNAQEBBQADgYsAMIGHAoGBAI8A3ay+oRKRBAD4oojA2s4feHBHn5OafJ+Vxap7wsd3IF/qBrXdnFLxfvLltCSZDarajwTjxX2rhT7Q0hm3Yyy6DnyaMoL8u//c6HCv47SFNJ4JEgu2WP9M/xNU2m+JiABX+K/nwoWfE1VIYueJWL9ftCBOG099QBCsCrpdFUcbAgERMA0GCSqGSIb3DQEBBQUAA4GBAHV+uMPliZPhfLdcMGIbYQnWY2m4YrU/IvqZK4HTKyzG/heAp7+OvkGiC0YJHtvWehgZUV9ukVEbl93rCKmXlb6BuPgN60U1iLYJQ9nAVHm7fRoAjvjDj3CGFtmYb81sYu8sc5GHqsCbvTKHwW/x2O3uLJBM5ApDlcczmgdm8xqQ";

			var cerBytes = Convert.FromBase64String (Cert);
			var cert = new X509Certificate2 (cerBytes);
			var collection = new X509Certificate2Collection ();

			var found = collection.Find (X509FindType.FindBySubjectName, "SomeElse", false);
			Assert.AreEqual (0, found.Count, "empty");
			
			collection.Add (cert);

			collection.Find (X509FindType.FindBySubjectName, "T=SomeElse", false);
			Assert.AreEqual (0, found.Count, "with prefix");
			
			found = collection.Find (X509FindType.FindBySubjectName, "SomeElse", false);
			Assert.That (found.Count == 1, "full");
			
			found = collection.Find (X509FindType.FindBySubjectName, "Else", false);
			Assert.That (found.Count == 1, "partial");
			
			Assert.That (found [0].SubjectName.Name.Contains ("O=Root"));
			Assert.That (found [0].SubjectName.Name.Contains ("T=SomeElse"));
			Assert.That (found [0].SubjectName.Name.Contains ("CN=MyCNName"));
			found = collection.Find (X509FindType.FindBySubjectName, "MyCNName", false);
			Assert.IsTrue (found.Count == 1);
			Assert.That (found [0].SubjectName.Name.Contains ("O=Root"));
			Assert.That (found [0].SubjectName.Name.Contains ("T=SomeElse"));
			Assert.That (found [0].SubjectName.Name.Contains ("CN=MyCNName"));
			found = collection.Find (X509FindType.FindBySubjectName, "Root", false);
			Assert.IsTrue (found.Count == 1);
			Assert.That (found [0].SubjectName.Name.Contains ("O=Root"));
			Assert.That (found [0].SubjectName.Name.Contains ("T=SomeElse"));
			Assert.That (found [0].SubjectName.Name.Contains ("CN=MyCNName"));
			found = collection.Find (X509FindType.FindBySubjectName, "SomeRandomStringThatDoesn'tExist", false);
			Assert.AreEqual (0, found.Count);
		}
	}
}

#endif