1
//-----------------------------------------------------------------------
2 // <copyright file="CollectionAssert.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
.Test
.Messaging
{
8 using System
.Collections
;
9 using System
.Collections
.Generic
;
11 using DotNetOpenAuth
.Messaging
;
12 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
14 internal class CollectionAssert
<T
> {
15 internal static void AreEquivalent(ICollection
<T
> expected
, ICollection
<T
> actual
) {
16 ErrorUtilities
.VerifyArgumentNotNull(expected
, "expected");
17 ErrorUtilities
.VerifyArgumentNotNull(actual
, "actual");
19 ICollection expectedNonGeneric
= new List
<T
>(expected
);
20 ICollection actualNonGeneric
= new List
<T
>(actual
);
21 CollectionAssert
.AreEquivalent(expectedNonGeneric
, actualNonGeneric
);
24 internal static void AreEquivalentByEquality(ICollection
<T
> expected
, ICollection
<T
> actual
) {
25 ErrorUtilities
.VerifyArgumentNotNull(expected
, "expected");
26 ErrorUtilities
.VerifyArgumentNotNull(actual
, "actual");
28 Assert
.AreEqual(expected
.Count
, actual
.Count
);
29 foreach (T
value in expected
) {
30 Assert
.IsTrue(actual
.Contains(value));
34 internal static void Contains(IEnumerable
<T
> sequence
, T element
) {
35 ErrorUtilities
.VerifyArgumentNotNull(sequence
, "sequence");
37 if (!sequence
.Contains(element
)) {
38 Assert
.Fail("Sequence did not include expected element '{0}'.", element
);