Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Model-View-ViewModel in WPF

, 21 Dec 2007 CPOL
An article on creating WPF applications, following the Model-View-ViewModel pattern.
codeproject.zip
CodeProject
.bzr
.bzrignore
branch
branch-format
branch-lock
branch-name
format
lock
revision-history
checkout
conflicts
dirstate
format
lock
README
repository
format
inventory.kndx
inventory.knit
knits
01
assemblyinfo.cs-20071213013430-sngkh9ui5e83ud60-8.kndx
assemblyinfo.cs-20071213013430-sngkh9ui5e83ud60-8.knit
tasklist.datamodel-20071213014434-wjgek8uvcjo8yp5s-1.kndx
tasklist.datamodel-20071213014434-wjgek8uvcjo8yp5s-1.knit
08
properties-20071213014434-wjgek8uvcjo8yp5s-3.kndx
properties-20071213014434-wjgek8uvcjo8yp5s-3.knit
0a
taskcollectiontest.c-20071213180529-6351e013ut030x8d-1.kndx
taskcollectiontest.c-20071213180529-6351e013ut030x8d-1.knit
10
tasklist.viewmodel-20071213212525-zmxqp3frjbsg0b0z-1.kndx
tasklist.viewmodel-20071213212525-zmxqp3frjbsg0b0z-1.knit
15
itasklistapplication-20071213212525-zmxqp3frjbsg0b0z-3.kndx
itasklistapplication-20071213212525-zmxqp3frjbsg0b0z-3.knit
16
resources.designer.c-20071213035543-53ny0xm8ahdeup8a-3.kndx
resources.designer.c-20071213035543-53ny0xm8ahdeup8a-3.knit
19
assemblyinfo.cs-20071213213342-s7iwkoswpulzwbg4-5.kndx
assemblyinfo.cs-20071213213342-s7iwkoswpulzwbg4-5.knit
1b
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-10.kndx
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-10.knit
27
commandsinkattribute-20071214020122-tzvrpu3a2hvv9ioh-1.kndx
commandsinkattribute-20071214020122-tzvrpu3a2hvv9ioh-1.knit
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-1.kndx
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-1.knit
2a
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-4.kndx
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-4.knit
2c
tasklistviewmodel.cs-20071213213222-558xu0jc4awt8fgg-1.kndx
tasklistviewmodel.cs-20071213213222-558xu0jc4awt8fgg-1.knit
32
selection.cs-20071215202735-qp5k90odcm8iomjv-1.kndx
selection.cs-20071215202735-qp5k90odcm8iomjv-1.knit
38
testdataerrorinfo.cs-20071213023410-3b817j85lvxslkns-1.kndx
testdataerrorinfo.cs-20071213023410-3b817j85lvxslkns-1.knit
3a
tasklistcommands.cs-20071215160037-lz7a3je7txcjyri5-1.kndx
tasklistcommands.cs-20071215160037-lz7a3je7txcjyri5-1.knit
3c
edittaskpage.xaml-20071215212433-9gnk5rr3mjw0gjrf-1.kndx
edittaskpage.xaml-20071215212433-9gnk5rr3mjw0gjrf-1.knit
properties-20071213013430-sngkh9ui5e83ud60-6.kndx
properties-20071213013430-sngkh9ui5e83ud60-6.knit
3f
taskcollection.cs-20071213181230-6z9ws0p8k1vkjzuc-1.kndx
taskcollection.cs-20071213181230-6z9ws0p8k1vkjzuc-1.knit
40
mainwindowviewmodelt-20071213213449-ns60l2kj4h237pzg-1.kndx
mainwindowviewmodelt-20071213213449-ns60l2kj4h237pzg-1.knit
41
edittaskpage.xaml.cs-20071215212433-9gnk5rr3mjw0gjrf-2.kndx
edittaskpage.xaml.cs-20071215212433-9gnk5rr3mjw0gjrf-2.knit
45
globalsuppressions.c-20071217043309-o86x25nntk0bk6lo-1.kndx
globalsuppressions.c-20071217043309-o86x25nntk0bk6lo-1.knit
4c
globalsuppressions.c-20071213211235-souqg3uilzehioee-1.kndx
globalsuppressions.c-20071213211235-souqg3uilzehioee-1.knit
4e
localtestrun.testrun-20071213013430-sngkh9ui5e83ud60-2.kndx
localtestrun.testrun-20071213013430-sngkh9ui5e83ud60-2.knit
4f
precondition.cs-20071213022255-ecv7q7up7nar12vq-1.kndx
precondition.cs-20071213022255-ecv7q7up7nar12vq-1.knit
51
codeproject.snk-20071213021143-3x1ioaofarxdc7k2-2.kndx
codeproject.snk-20071213021143-3x1ioaofarxdc7k2-2.knit
54
properties-20071213213342-s7iwkoswpulzwbg4-3.kndx
properties-20071213213342-s7iwkoswpulzwbg4-3.knit
57
tasktest.cs-20071213013555-48d7c3agymuoj2i0-1.kndx
tasktest.cs-20071213013555-48d7c3agymuoj2i0-1.knit
58
assemblyinfo.cs-20071213021143-3x1ioaofarxdc7k2-5.kndx
assemblyinfo.cs-20071213021143-3x1ioaofarxdc7k2-5.knit
5e
iedittaskpageview.cs-20071217021058-4xiyah3s4mh60qow-1.kndx
iedittaskpageview.cs-20071217021058-4xiyah3s4mh60qow-1.knit
61
assemblyinfo.cs-20071213022943-ws0x3cedbvac5k3p-5.kndx
assemblyinfo.cs-20071213022943-ws0x3cedbvac5k3p-5.knit
67
codeprojectcore.cspr-20071213021143-3x1ioaofarxdc7k2-3.kndx
codeprojectcore.cspr-20071213021143-3x1ioaofarxdc7k2-3.knit
6d
tasklistpageviewmode-20071215194732-4g7n1tutd5u4iig0-4.kndx
tasklistpageviewmode-20071215194732-4g7n1tutd5u4iig0-4.knit
71
codeproject.sln-20071213013011-q70xfq7n7ogllazi-1.kndx
codeproject.sln-20071213013011-q70xfq7n7ogllazi-1.knit
76
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-1.kndx
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-1.knit
79
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-4.kndx
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-4.knit
7f
authoringtests.txt-20071213013430-sngkh9ui5e83ud60-4.kndx
authoringtests.txt-20071213013430-sngkh9ui5e83ud60-4.knit
codeprojectcore-20071213021143-3x1ioaofarxdc7k2-1.kndx
codeprojectcore-20071213021143-3x1ioaofarxdc7k2-1.knit
86
resources.resx-20071213013237-ucb9omrtgj50gglg-16.kndx
resources.resx-20071213013237-ucb9omrtgj50gglg-16.knit
8a
bzrignore-20071213012954-kvrppfyxdd192lwi-1.kndx
bzrignore-20071213012954-kvrppfyxdd192lwi-1.knit
8d
resources.resx-20071213211717-wf3kh2bgsnduzgg4-12.kndx
resources.resx-20071213211717-wf3kh2bgsnduzgg4-12.knit
90
viewmodel.cs-20071214020122-tzvrpu3a2hvv9ioh-2.kndx
viewmodel.cs-20071214020122-tzvrpu3a2hvv9ioh-2.knit
93
codeproject.snk-20071213013237-ucb9omrtgj50gglg-3.kndx
codeproject.snk-20071213013237-ucb9omrtgj50gglg-3.knit
94
properties-20071213021143-3x1ioaofarxdc7k2-4.kndx
properties-20071213021143-3x1ioaofarxdc7k2-4.knit
95
tasklist.datamodel.c-20071213014434-wjgek8uvcjo8yp5s-4.kndx
tasklist.datamodel.c-20071213014434-wjgek8uvcjo8yp5s-4.knit
97
stringlengthvalidato-20071213035543-53ny0xm8ahdeup8a-2.kndx
stringlengthvalidato-20071213035543-53ny0xm8ahdeup8a-2.knit
98
authoringtests.txt-20071213213342-s7iwkoswpulzwbg4-2.kndx
authoringtests.txt-20071213213342-s7iwkoswpulzwbg4-2.knit
9c
properties-20071213022943-ws0x3cedbvac5k3p-3.kndx
properties-20071213022943-ws0x3cedbvac5k3p-3.knit
9f
codeproject.snk-20071213211717-wf3kh2bgsnduzgg4-4.kndx
codeproject.snk-20071213211717-wf3kh2bgsnduzgg4-4.knit
a5
resources.designer.c-20071213013237-ucb9omrtgj50gglg-15.kndx
resources.designer.c-20071213013237-ucb9omrtgj50gglg-15.knit
tasklist.viewmodel.c-20071213212525-zmxqp3frjbsg0b0z-5.kndx
tasklist.viewmodel.c-20071213212525-zmxqp3frjbsg0b0z-5.knit
a6
tasklisttestapplicat-20071213214943-dyyzzbvhjnv2ggob-1.kndx
tasklisttestapplicat-20071213214943-dyyzzbvhjnv2ggob-1.knit
ac
resources.designer.c-20071213211717-wf3kh2bgsnduzgg4-11.kndx
resources.designer.c-20071213211717-wf3kh2bgsnduzgg4-11.knit
ae
specify.cs-20071213013237-ucb9omrtgj50gglg-12.kndx
specify.cs-20071213013237-ucb9omrtgj50gglg-12.knit
af
imainwindowview.cs-20071214025649-nyfq33grd351tyuj-1.kndx
imainwindowview.cs-20071214025649-nyfq33grd351tyuj-1.knit
b1
mainwindow.xaml-20071213211717-wf3kh2bgsnduzgg4-5.kndx
mainwindow.xaml-20071213211717-wf3kh2bgsnduzgg4-5.knit
b2
app.xaml-20071213211717-wf3kh2bgsnduzgg4-2.kndx
app.xaml-20071213211717-wf3kh2bgsnduzgg4-2.knit
b3
tasklist.csproj.user-20071213211717-wf3kh2bgsnduzgg4-9.kndx
tasklist.csproj.user-20071213211717-wf3kh2bgsnduzgg4-9.knit
b4
codeproject.snk-20071213212525-zmxqp3frjbsg0b0z-2.kndx
codeproject.snk-20071213212525-zmxqp3frjbsg0b0z-2.knit
frameworkmessages.cs-20071213013237-ucb9omrtgj50gglg-6.kndx
frameworkmessages.cs-20071213013237-ucb9omrtgj50gglg-6.knit
b6
mainwindow.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-6.kndx
mainwindow.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-6.knit
b7
app.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-3.kndx
app.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-3.knit
settings.designer.cs-20071213211717-wf3kh2bgsnduzgg4-13.kndx
settings.designer.cs-20071213211717-wf3kh2bgsnduzgg4-13.knit
bc
assemblyinfo.cs-20071213212525-zmxqp3frjbsg0b0z-6.kndx
assemblyinfo.cs-20071213212525-zmxqp3frjbsg0b0z-6.knit
bd
app.config-20071215154029-mlxydmaa3bclnaag-1.kndx
app.config-20071215154029-mlxydmaa3bclnaag-1.knit
be
edittaskpageviewmode-20071215212433-9gnk5rr3mjw0gjrf-3.kndx
edittaskpageviewmode-20071215212433-9gnk5rr3mjw0gjrf-3.knit
c0
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-1.kndx
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-1.knit
c1
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-2.kndx
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-2.knit
c2
tasklistpageviewmode-20071215200239-p788d71fwwxauwrm-1.kndx
tasklistpageviewmode-20071215200239-p788d71fwwxauwrm-1.knit
c5
commandtester.cs-20071214020412-lzl7v3k2q5et9xoj-1.kndx
commandtester.cs-20071214020412-lzl7v3k2q5et9xoj-1.knit
specificationvalue.c-20071213013237-ucb9omrtgj50gglg-11.kndx
specificationvalue.c-20071213013237-ucb9omrtgj50gglg-11.knit
tasklist.csproj-20071213211717-wf3kh2bgsnduzgg4-8.kndx
tasklist.csproj-20071213211717-wf3kh2bgsnduzgg4-8.knit
c6
codeproject.snk-20071213014434-wjgek8uvcjo8yp5s-2.kndx
codeproject.snk-20071213014434-wjgek8uvcjo8yp5s-2.knit
c9
assemblyinfo.cs-20071213013237-ucb9omrtgj50gglg-14.kndx
assemblyinfo.cs-20071213013237-ucb9omrtgj50gglg-14.knit
ca
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-4.kndx
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-4.knit
cb
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-5.kndx
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-5.knit
cc
testextensions.cs-20071213013237-ucb9omrtgj50gglg-13.kndx
testextensions.cs-20071213013237-ucb9omrtgj50gglg-13.knit
cd
assemblyinfo.cs-20071213014434-wjgek8uvcjo8yp5s-5.kndx
assemblyinfo.cs-20071213014434-wjgek8uvcjo8yp5s-5.knit
codeproject.vsmdi-20071213013430-sngkh9ui5e83ud60-1.kndx
codeproject.vsmdi-20071213013430-sngkh9ui5e83ud60-1.knit
d0
assemblyinfo.cs-20071213211717-wf3kh2bgsnduzgg4-10.kndx
assemblyinfo.cs-20071213211717-wf3kh2bgsnduzgg4-10.knit
d2
mainwindowviewmodel.-20071214021535-pfu4qerfstp78gcd-1.kndx
mainwindowviewmodel.-20071214021535-pfu4qerfstp78gcd-1.knit
d4
manualtest1.mht-20071213013430-sngkh9ui5e83ud60-5.kndx
manualtest1.mht-20071213013430-sngkh9ui5e83ud60-5.knit
settings.settings-20071213211717-wf3kh2bgsnduzgg4-14.kndx
settings.settings-20071213211717-wf3kh2bgsnduzgg4-14.knit
d6
task.cs-20071213014820-kfzciheohayefljq-1.kndx
task.cs-20071213014820-kfzciheohayefljq-1.knit
d9
properties-20071213013237-ucb9omrtgj50gglg-8.kndx
properties-20071213013237-ucb9omrtgj50gglg-8.knit
de
itasklistpageview.cs-20071215201802-5gm7npkr8rynfbpn-1.kndx
itasklistpageview.cs-20071215201802-5gm7npkr8rynfbpn-1.knit
e0
authoringtests.txt-20071213022943-ws0x3cedbvac5k3p-2.kndx
authoringtests.txt-20071213022943-ws0x3cedbvac5k3p-2.knit
e3
dataerrorinfo.cs-20071213023841-9p8uxe73oezcfbdz-1.kndx
dataerrorinfo.cs-20071213023841-9p8uxe73oezcfbdz-1.knit
properties-20071213211717-wf3kh2bgsnduzgg4-7.kndx
properties-20071213211717-wf3kh2bgsnduzgg4-7.knit
ea
tasklistpage.xaml-20071215194732-4g7n1tutd5u4iig0-1.kndx
tasklistpage.xaml-20071215194732-4g7n1tutd5u4iig0-1.knit
ed
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-3.kndx
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-3.knit
ef
tasklistpage.xaml.cs-20071215194732-4g7n1tutd5u4iig0-2.kndx
tasklistpage.xaml.cs-20071215194732-4g7n1tutd5u4iig0-2.knit
f1
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-7.kndx
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-7.knit
f3
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-9.kndx
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-9.knit
f4
objectextensions.cs-20071213035543-53ny0xm8ahdeup8a-1.kndx
objectextensions.cs-20071213035543-53ny0xm8ahdeup8a-1.knit
f5
numerics.cs-20071213013237-ucb9omrtgj50gglg-7.kndx
numerics.cs-20071213013237-ucb9omrtgj50gglg-7.knit
f7
properties-20071213212525-zmxqp3frjbsg0b0z-4.kndx
properties-20071213212525-zmxqp3frjbsg0b0z-4.knit
resources.resx-20071213035543-53ny0xm8ahdeup8a-4.kndx
resources.resx-20071213035543-53ny0xm8ahdeup8a-4.knit
f9
validatorattribute.c-20071213025856-7hxu8ce3k2040pyr-1.kndx
validatorattribute.c-20071213025856-7hxu8ce3k2040pyr-1.knit
fe
titleconverter.cs-20071215194732-4g7n1tutd5u4iig0-3.kndx
titleconverter.cs-20071215194732-4g7n1tutd5u4iig0-3.knit
ff
tasklist-20071213211717-wf3kh2bgsnduzgg4-1.kndx
tasklist-20071213211717-wf3kh2bgsnduzgg4-1.knit
lock
revision-store
revisions.kndx
revisions.knit
signatures.kndx
signatures.knit
CodeProject.suo
CodeProject.VisualStudio.QualityTools.UnitTestFramework
bin
Debug
CodeProject.snk
obj
Debug
Refactor
CodeProject.VisualStudio.QualityTools.UnitTestFramework.dll
TempPE
Properties.Resources.Designer.cs.dll
Properties
CodeProject.vsmdi
CodeProjectCore
bin
Debug
CodeProject.snk
obj
Debug
Refactor
CodeProjectCore.dll
TempPE
Properties.Resources.Designer.cs.dll
Properties
LocalTestRun.testrunconfig
TaskList
TaskList.DataModel
bin
Debug
CodeProject.snk
obj
Debug
Refactor
TaskList.DataModel.dll
TempPE
Properties
TaskList.ViewModel
bin
Debug
CodeProject.snk
obj
Debug
Refactor
TaskList.ViewModel.dll
TempPE
Properties
bin
Debug
TaskList.vshost.exe
TaskList.vshost.exe.manifest
CodeProject.snk
obj
Debug
Refactor
TempPE
Properties.Resources.Designer.cs.dll
Properties
Settings.settings
TaskList.csproj.user
Test.CodeProjectCore
bin
Debug
obj
Debug
Refactor
TempPE
Properties
Test.TaskList.DataModel
bin
Debug
obj
Debug
Refactor
TempPE
Properties
Test.TaskList.ViewModel
bin
Debug
obj
Debug
Refactor
TempPE
Properties
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CodeProject.VisualStudio.QualityTools.UnitTestFramework
{
    /// <summary>
    /// Provides extensions methods that allow you to specify requirements
    /// in a fluent language.
    /// </summary>
    public static class Specify
    {
        #region Specification starters

        /// <summary>
        /// Wraps a value in a <see cref="SpecificationValue&lt;T&gt;"/>.
        /// This provides a way to start to describe a specification in a
        /// fluent language.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>The value wrapped in a <see cref="SpecificationValue&lt;T&gt;/>.</returns>
        public static SpecificationValue<object> That(object value)
        {
            return That<object>(value);
        }

        /// <summary>
        /// Wraps a value in a <see cref="SpecificationValue&lt;T&gt;"/>.
        /// This provides a way to start to describe a specification in a
        /// fluent language.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>The value wrapped in a <see cref="SpecificationValue&lt;T&gt;/>.</returns>
        public static SpecificationValue<T> That<T>(T value)
        {
            return new SpecificationValue<T>(value);
        }

        /// <summary>
        /// Wraps an <see cref="Action"/> delegate in a <see cref="SpecificationValue&lt;T&gt;"/>.
        /// This provides a way to start to describe an exception specification
        /// in a fluent language.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        public static SpecificationValue<Action> ThatAction(Action action)
        {
            return new SpecificationValue<Action>(action);
        }

        #endregion

        #region Exception specifications

        /// <summary>
        /// Specifies that an <see cref="Action"/> should throw an exception
        /// of a specified type.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        /// <returns>The exception caught when executing the <see cref="Action"/>.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        public static T ShouldThrow<T>(this SpecificationValue<Action> self) where T : Exception
        {
            return ShouldThrow<T>(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that an <see cref="Action"/> should throw an exception
        /// of a specified type.  Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// <returns>The exception caught when executing the <see cref="Action"/>.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        public static T ShouldThrow<T>(this SpecificationValue<Action> self, string message) where T : Exception
        {
            return ShouldThrow<T>(self, message, null);
        }

        /// <summary>
        /// Specifies that an <see cref="Action"/> should throw an exception
        /// of a specified type.  Displays a message if the specification fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting
        /// message.</param>
        /// <returns>The exception caught when executing the <see cref="Action"/>.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        public static T ShouldThrow<T>(this SpecificationValue<Action> self, string message, params object[] parameters) where T : Exception
        {
            Action action = self.Value;
            try
            {
                action();
            }
            catch (Exception e)
            {
                Type actualType = e.GetType();
                Type expectedType = typeof(T);
                if (!actualType.Equals(expectedType))
                {
                    Fail("ShouldThrow",
                        FrameworkMessages.ExceptionTypeMismatch(expectedType, actualType),
                        message, parameters);
                }
                return (T)e;
            }
            Fail("ShouldThrow",
                FrameworkMessages.ExceptionNotThrown(typeof(T)),
                message, parameters);
            return null; // Will never get here, but must satisfy the compiler
        }

        /// <summary>
        /// Specifies that an <see cref="Action"/> should not throw an exception.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        public static void ShouldNotThrow(this SpecificationValue<Action> self)
        {
            ShouldNotThrow(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that an <see cref="Action"/> should not throw an exception.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// message.</param>
        public static void ShouldNotThrow(this SpecificationValue<Action> self, string message)
        {
            ShouldNotThrow(self, message, null);
        }

        /// <summary>
        /// Specifies that an <see cref="Action"/> should not throw an exception.
        /// Displays a message if the specification fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <typeparam name="T">The exception type to expect.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// <see cref="Action"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting
        /// message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "e")]
        public static void ShouldNotThrow(this SpecificationValue<Action> self, string message, params object[] parameters)
        {
            Action action = self.Value;
            try
            {
                action();
            }
            catch (Exception e)
            {
                Fail("ShouldNotThrow",
                    FrameworkMessages.UnexpectedException(e.GetType()),
                    message, parameters);
            }
        }

        #endregion

        #region General specifications

        /// <summary>
        /// Specifies that the specified condition should be <value>false</value>.
        /// The specification fails if the condition is <value>true</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>false</value>.</param>
        public static void ShouldBeFalse(this SpecificationValue<bool> self)
        {
            ShouldBeFalse(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that the specified condition should be <value>false</value>.
        /// The specification fails if the condition is <value>true</value>.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>false</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        public static void ShouldBeFalse(this SpecificationValue<bool> self, string message)
        {
            ShouldBeFalse(self, message, null);
        }

        /// <summary>
        /// Specifies that the specified condition should be <value>false</value>.
        /// The specification fails if the condition is <value>true</value>.
        /// Displays a message if the specification fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>false</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting
        /// message.</param>
        public static void ShouldBeFalse(this SpecificationValue<bool> self, string message, params object[] parameters)
        {
            bool value = self.Value;
            if (value)
                Fail("ShouldBeFalse", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that the specified condition should be <value>true</value>.
        /// The specification fails if the condition is <value>false</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>true</value>.</param>
        public static void ShouldBeTrue(this SpecificationValue<bool> self)
        {
            ShouldBeTrue(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that the specified condition should be <value>true</value>.
        /// The specification fails if the condition is <value>false</value>.
        ///  Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>true</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        public static void ShouldBeTrue(this SpecificationValue<bool> self, string message)
        {
            ShouldBeTrue(self, message, null);
        }

        /// <summary>
        /// Specifies that the specified condition should be <value>true</value>.
        /// The specification fails if the condition is <value>false</value>.
        /// Displays a message if the specification fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// condition to verify is <value>true</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This
        /// message can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting
        /// message.</param>
        public static void ShouldBeTrue(this SpecificationValue<bool> self, string message, params object[] parameters)
        {
            bool value = self.Value;
            if (!value)
                Fail("ShouldBeTrue", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that two objects should be equal. The specification fails
        /// if the objects are not equal. Displays a message if the specification fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped object
        /// to compare. This is the object the specification test produced.</param>
        /// <param name="expected">The object to compare the specification value to.
        /// This is the object the specification expects.</param>
        public static void ShouldEqual<T>(this SpecificationValue<T> self, object expected)
        {
            ShouldEqual<T, object>(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two objects should be equal. The specification fails
        /// if the objects are not equal. Displays a message if the specification fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped object
        /// to compare. This is the object the specification test produced.</param>
        /// <param name="expected">The object to compare the specification value to.
        /// This is the object the specification expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldEqual<T>(this SpecificationValue<T> self, object expected, string message)
        {
            ShouldEqual<T, object>(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that two objects should be equal. The specification fails
        /// if the objects are not equal. Displays a message if the specification fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped object
        /// to compare. This is the object the specification test produced.</param>
        /// <param name="expected">The object to compare the specification value to.
        /// This is the object the specification expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldEqual<T>(this SpecificationValue<T> self, object expected, string message, params object[] parameters)
        {
            ShouldEqual<T, object>(self, expected, message, parameters);
        }

        /// <summary>
        /// Specifies that two generic type data should be equal. The specification
        /// fails if they are not equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected)
        {
            ShouldEqual(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two generic type data should be equal. The specification
        /// fails if they are not equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected, string message)
        {
            ShouldEqual(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that two generic type data should be equal. The specification
        /// fails if they are not equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected, string message, params object[] parameters)
        {
            T1 actual = self.Value;

            if (Numerics.IsNumeric<T1>() && Numerics.IsNumeric<T2>())
            {
                if (!Numerics.AreEqual(actual, expected, 0))
                    Fail("ShouldEqual",
                        FrameworkMessages.UnequalValues(expected, actual),
                        message, parameters);
            }
            else
            {
                ICollection actualCollection = actual as ICollection;
                ICollection expectedCollection = expected as ICollection;
                if (actualCollection != null && expectedCollection != null)
                {
                    string reason = string.Empty;
                    if (!AreCollectionsEqual(actualCollection, expectedCollection,
                        new ObjectComparer(), ref reason))
                    {
                        Fail("ShouldEqual", reason, message, parameters);
                    }
                }
                else if (!object.Equals(actual, expected))
                {
                    Fail("ShouldEqual",
                        FrameworkMessages.UnequalValues(expected, actual),
                        message, parameters);
                }
            }
        }

        /// <summary>
        /// Specifies that two generic type data should not be equal. The specification
        /// fails if they are equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected)
        {
            ShouldNotEqual(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two generic type data should not be equal. The specification
        /// fails if they are equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected, string message)
        {
            ShouldNotEqual(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that two generic type data should not be equal. The specification
        /// fails if they are equal.
        /// </summary>
        /// <typeparam name="T1">The type of the specified value.</typeparam>
        /// <typeparam name="T2">The type of the expected value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// generic type data to compare. This is the generic type data the specification
        /// test produced.</param>
        /// <param name="expected">The generic type data to compare to the specified value.
        /// This is the generic type data the specification test expects.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T1, T2>(this SpecificationValue<T1> self, T2 expected, string message, params object[] parameters)
        {
            T1 actual = self.Value;

            if (Numerics.IsNumeric<T1>() && Numerics.IsNumeric<T2>())
            {
                if (Numerics.AreEqual(actual, expected, 0))
                    Fail("ShouldNotEqual", string.Empty, message, parameters);
            }
            else
            {
                ICollection actualCollection = actual as ICollection;
                ICollection expectedCollection = expected as ICollection;
                if (actualCollection != null && expectedCollection != null)
                {
                    string reason = string.Empty;
                    if (AreCollectionsEqual(actualCollection, expectedCollection, new ObjectComparer(), ref reason))
                    {
                        Fail("ShouldNotEqual", reason, message, parameters);
                    }
                }
                else if (object.Equals(actual, expected))
                {
                    Fail("ShouldNotEqual", string.Empty, message, parameters);
                }
            }
        }

        /// <summary>
        /// Specifies that two numeric values should be equal, or within the specified
        /// accuracy of each other. The specification fails if they are not within the
        /// specified accuracy of each other.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T>(this SpecificationValue<T> self, T expected, T delta)
        {
            ShouldEqual(self, expected, delta, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two numeric values should be equal, or within the specified
        /// accuracy of each other. The specification fails if they are not within the
        /// specified accuracy of each other. Displays a message if the assertion fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T>(this SpecificationValue<T> self, T expected, T delta, string message)
        {
            ShouldEqual(self, expected, delta, message, null);
        }

        /// <summary>
        /// Specifies that two numeric values should be equal, or within the specified
        /// accuracy of each other. The specification fails if they are not within the
        /// specified accuracy of each other. Displays a message if the assertion fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldEqual<T>(this SpecificationValue<T> self, T expected, T delta, string message, params object[] parameters)
        {
            if (!Numerics.IsNumeric<T>())
            {
                Fail("ShouldEqual",
                    FrameworkMessages.NumericTypeExpected(typeof(T)),
                    message, parameters);
            }
            T actual = self.Value;
            if (!Numerics.AreEqual(actual, expected, delta))
            {
                Fail("ShouldEqual",
                    FrameworkMessages.DifferenceTooGreat(expected, actual, delta),
                    message, parameters);
            }
        }

        /// <summary>
        /// Specifies that two numeric values should not be equal, or within the specified
        /// accuracy of each other. The specification fails if they are within the
        /// specified accuracy of each other.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is not different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T>(this SpecificationValue<T> self, T expected, T delta)
        {
            ShouldNotEqual(self, expected, delta, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two numeric values should not be equal, or within the specified
        /// accuracy of each other. The specification fails if they are within the
        /// specified accuracy of each other. Displays a message if the assertion fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is not different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T>(this SpecificationValue<T> self, T expected, T delta, string message)
        {
            ShouldNotEqual(self, expected, delta, message, null);
        }

        /// <summary>
        /// Specifies that two numeric values should not be equal, or within the specified
        /// accuracy of each other. The specification fails if they are within the
        /// specified accuracy of each other. Displays a message if the assertion fails,
        /// and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value. This must be a
        /// numeric type.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/> wrapped
        /// numeric data to compare. This is the numeric data the specification
        /// test produced.</param>
        /// <param name="expected">The numeric data to compare to the specified value.
        /// This is the numeric data the specification test expects.</param>
        /// <param name="delta">The required accuracy. The specification will fail only
        /// if <paramref name="expected"/> is not different from <paramref name="actual"/>
        /// by more than <paramref name="delta"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "2")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "1")]
        public static void ShouldNotEqual<T>(this SpecificationValue<T> self, T expected, T delta, string message, params object[] parameters)
        {
            if (!Numerics.IsNumeric<T>())
            {
                Fail("ShouldEqual",
                    FrameworkMessages.NumericTypeExpected(typeof(T)),
                    message, parameters);
            }
            T actual = self.Value;
            if (Numerics.AreEqual(actual, expected, delta))
            {
                Fail("ShouldEqual",
                    FrameworkMessages.DifferenceTooLittle(expected, actual, delta),
                    message, parameters);
            }
        }

        /// <summary>
        /// Specifies that a specified object reference should be null. The
        /// specification fails if it is not <value>null</value>.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        public static void ShouldBeNull<T>(this SpecificationValue<T> self)
        {
            ShouldBeNull(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified object reference should be null. The
        /// specification fails if it is not <value>null</value>.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeNull<T>(this SpecificationValue<T> self, string message)
        {
            ShouldBeNull(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified object reference should be null. The
        /// specification fails if it is not <value>null</value>.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeNull<T>(this SpecificationValue<T> self, string message, params object[] parameters)
        {
            object actual = self.Value;
            if (actual != null)
            {
                Fail("ShouldBeNull",
                    FrameworkMessages.NotNull(actual),
                    message, parameters);
            }
        }

        /// <summary>
        /// Specifies that a specified object reference should not be null. The
        /// specification fails if it is <value>null</value>.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        public static void ShouldNotBeNull<T>(this SpecificationValue<T> self)
        {
            ShouldNotBeNull(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified object reference should not be null. The
        /// specification fails if it is <value>null</value>.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeNull<T>(this SpecificationValue<T> self, string message)
        {
            ShouldNotBeNull(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified object reference should not be null. The
        /// specification fails if it is <value>null</value>.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is <value>null</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeNull<T>(this SpecificationValue<T> self, string message, params object[] parameters)
        {
            object actual = self.Value;
            if (actual == null)
                Fail("ShouldNotBeNull", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that the specified object is an instance of the specified type.
        /// The specification fails if the type is not found in the inheritance hierarchy
        /// of the object.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        public static void ShouldBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType)
        {
            ShouldBeInstanceOfType(self, expectedType, string.Empty, null);
        }

        /// <summary>
        /// Specifies that the specified object is an instance of the specified type.
        /// The specification fails if the type is not found in the inheritance hierarchy
        /// of the object. Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType, string message)
        {
            ShouldBeInstanceOfType(self, expectedType, message, null);
        }

        /// <summary>
        /// Specifies that the specified object is an instance of the specified type.
        /// The specification fails if the type is not found in the inheritance hierarchy
        /// of the object. Displays a message if the specification fails, and applies
        /// the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType, string message, params object[] parameters)
        {
            if (expectedType == null)
                Fail("ShouldBeInstanceOfType", string.Empty, message, parameters);
            if (!expectedType.IsInstanceOfType(self.Value))
            {
                Fail("ShouldBeInstanceOfType",
                    string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that the specified object should not be an instance of the specified
        /// type. The specification fails if the type is not found in the inheritance
        /// hierarchy of the object.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to not be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        public static void ShouldNotBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType)
        {
            ShouldNotBeInstanceOfType(self, expectedType, string.Empty, null);
        }

        /// <summary>
        /// Specifies that the specified object should not be an instance of the specified
        /// type. The specification fails if the type is not found in the inheritance
        /// hierarchy of the object. Displays a message if the specification fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to not be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType, string message)
        {
            ShouldNotBeInstanceOfType(self, expectedType, message, null);
        }

        /// <summary>
        /// Specifies that the specified object should not be an instance of the specified
        /// type. The specification fails if the type is not found in the inheritance
        /// hierarchy of the object. Displays a message if the specification fails, and
        /// applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified object.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to verify is of <paramref name="expectedType"/>.</param>
        /// <param name="expectedType">The type expected to not be found in the inheritance
        /// hierarchy of <paramref name="self"/>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeInstanceOfType<T>(this SpecificationValue<T> self, Type expectedType, string message, params object[] parameters)
        {
            if (expectedType == null)
                Fail("ShouldNotBeInstanceOfType", string.Empty, message, parameters);
            if (expectedType.IsInstanceOfType(self.Value))
            {
                Fail("ShouldNotBeInstanceOfType",
                    string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that two specified object variables should refer to the same object.
        /// The specification fails if they refer to different objects.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        public static void ShouldBeSameAs<T>(this SpecificationValue<T> self, object expected)
        {
            ShouldBeSameAs(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two specified object variables should refer to the same object.
        /// The specification fails if they refer to different objects. Displays a message
        /// if the assertion fails.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeSameAs<T>(this SpecificationValue<T> self, object expected, string message)
        {
            ShouldBeSameAs(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that two specified object variables should refer to the same object.
        /// The specification fails if they refer to different objects. Displays a message
        /// if the assertion fails, and applies the specified formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeSameAs<T>(this SpecificationValue<T> self, object expected, string message,
            params object[] parameters)
        {
            object actual = self.Value;
            if (actual.GetType().IsValueType || expected.GetType().IsValueType)
            {
                Fail("ShouldBeSameAs",
                    FrameworkMessages.ValueTypesGiven(),
                    message, parameters);
            }
            if (!object.ReferenceEquals(actual, expected))
            {
                Fail("ShouldBeSameAs", string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that two specified object variables should not refer to the same
        /// object. The specification fails if they refer to different objects.
        /// Displays a message if the assertion fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        public static void ShouldNotBeSameAs<T>(this SpecificationValue<T> self, object expected)
        {
            ShouldNotBeSameAs(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that two specified object variables should not refer to the same
        /// object. The specification fails if they refer to different objects.
        /// Displays a message if the assertion fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeSameAs<T>(this SpecificationValue<T> self, object expected, string message)
        {
            ShouldNotBeSameAs(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that two specified object variables should not refer to the same
        /// object. The specification fails if they refer to different objects.
        /// Displays a message if the assertion fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <typeparam name="T">The type of the specified value.</typeparam>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&gt;"/>
        /// wrapped object to compare to <paramref name="expectedType"/>.</param>
        /// <param name="expected">The expected object.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeSameAs<T>(this SpecificationValue<T> self, object expected, string message,
            params object[] parameters)
        {
            object actual = self.Value;
            if (object.ReferenceEquals(actual, expected))
                Fail("ShouldNotBeSameAs", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified single should ve <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped single to compare to <value>NaN</value>.</param>
        public static void ShouldBeNaN(this SpecificationValue<float> self)
        {
            ShouldBeNaN(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified single should ve <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped single to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeNaN(this SpecificationValue<float> self, string message)
        {
            ShouldBeNaN(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified single should ve <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped single to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeNaN(this SpecificationValue<float> self, string message, params object[] parameters)
        {
            if (!float.IsNaN(self.Value))
                Fail("ShouldBeNaN", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified double should be <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        public static void ShouldBeNaN(this SpecificationValue<double> self)
        {
            ShouldBeNaN(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified double should be <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>. Displays
        /// a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeNaN(this SpecificationValue<double> self, string message)
        {
            ShouldBeNaN(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified double should be <value>NaN</value>. The
        /// specification fails if the value is not <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeNaN(this SpecificationValue<double> self, string message, params object[] parameters)
        {
            if (!double.IsNaN(self.Value))
                Fail("ShouldBeNaN", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified single should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<float> self)
        {
            ShouldNotBeNaN(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified single should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>. Displays
        /// a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<float> self, string message)
        {
            ShouldNotBeNaN(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified single should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<float> self, string message, params object[] parameters)
        {
            if (float.IsNaN(self.Value))
                Fail("ShouldNotBeNaN", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified double should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<double> self)
        {
            ShouldNotBeNaN(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified double should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>. Displays
        /// a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<double> self, string message)
        {
            ShouldNotBeNaN(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified double should not be <value>NaN</value>. The
        /// specification fails if the value is <value>NaN</value>. Displays
        /// a message if the assertion fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped double to compare to <value>NaN</value>.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeNaN(this SpecificationValue<double> self, string message, params object[] parameters)
        {
            if (double.IsNaN(self.Value))
                Fail("ShouldNotBeNaN", string.Empty, message, parameters);
        }

        #endregion

        #region Collection specifications

        /// <summary>
        /// Specifies that a specified collection should only have items of a specified
        /// type. The specification fails if the collection has any items that are
        /// <value>null</value> or not of the specified type.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expectedType">The type expected.</param>
        public static void ShouldOnlyHaveItemsOfType<T>(this SpecificationValue<T> self, Type expectedType) where T : ICollection
        {
            ShouldOnlyHaveItemsOfType(self, expectedType, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should only have items of a specified
        /// type. The specification fails if the collection has any items that are
        /// <value>null</value> or not of the specified type. Displays a message if
        /// the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expectedType">The type expected.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldOnlyHaveItemsOfType<T>(this SpecificationValue<T> self, Type expectedType, string message) where T : ICollection
        {
            ShouldOnlyHaveItemsOfType(self, expectedType, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should only have items of a specified
        /// type. The specification fails if the collection has any items that are
        /// <value>null</value> or not of the specified type. Displays a message if
        /// the assertion fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expectedType">The type expected.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldOnlyHaveItemsOfType<T>(this SpecificationValue<T> self, Type expectedType, string message, params object[] parameters) where T : ICollection
        {
            foreach (object item in self.Value)
            {
                if (!expectedType.IsInstanceOfType(item))
                {
                    Fail("AllItemsShouldBeInstanceOfType",
                        string.Empty, message, parameters);
                }
            }
        }

        /// <summary>
        /// Specifies that a specified collection should not have <value>null</value> items.
        /// The specification fails if the collection has items that are <value>null</value>.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        public static void ShouldNotHaveNullItems<T>(this SpecificationValue<T> self) where T : ICollection
        {
            ShouldNotHaveNullItems(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not have <value>null</value> items.
        /// The specification fails if the collection has items that are <value>null</value>.
        /// Displays a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotHaveNullItems<T>(this SpecificationValue<T> self, string message) where T : ICollection
        {
            ShouldNotHaveNullItems(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not have <value>null</value> items.
        /// The specification fails if the collection has items that are <value>null</value>.
        /// Displays a message if the assertion fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotHaveNullItems<T>(this SpecificationValue<T> self, string message, params object[] parameters) where T : ICollection
        {
            foreach (object item in self.Value)
            {
                if (item == null)
                {
                    Fail("AllItemsShouldNotBeNull",
                        string.Empty, message, parameters);
                }
            }
        }

        /// <summary>
        /// Specifies that a specified collection should have unique items. The specification fails
        /// if the collection has any items that are not unique.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        public static void ShouldHaveUniqueItems<T>(this SpecificationValue<T> self) where T : ICollection
        {
            ShouldHaveUniqueItems(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should have unique items. The specification fails
        /// if the collection has any items that are not unique. Displays a message if the assertion
        /// fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldHaveUniqueItems<T>(this SpecificationValue<T> self,
            string message) where T : ICollection
        {
            ShouldHaveUniqueItems(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should have unique items. The specification fails
        /// if the collection has any items that are not unique. Displays a message if the assertion
        /// fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldHaveUniqueItems<T>(this SpecificationValue<T> self,
            string message, params object[] parameters) where T : ICollection
        {
            bool flag = false;
            Hashtable hashtable = new Hashtable();
            foreach (object item in self.Value)
            {
                if (item == null)
                {
                    if (!flag)
                    {
                        flag = true;
                    }
                    else
                    {
                        Fail("AllItemsShouldBeUnique", string.Empty, message, parameters);
                    }
                    continue;
                }
                if (hashtable[item] != null)
                {
                    Fail("AllItemsShouldBeUnique", string.Empty, message, parameters);
                    continue;
                }
                hashtable.Add(item, true);
            }
        }

        /// <summary>
        /// Specifies that a specified collection should be a subset of another collection.
        /// The specification fails if the collection is not a subset of the other collection.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        public static void ShouldBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset) where T : ICollection
        {
            ShouldBeSubsetOf(self, superset, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be a subset of another collection.
        /// The specification fails if the collection is not a subset of the other collection.
        /// Displays a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset, string message) where T : ICollection
        {
            ShouldBeSubsetOf(self, superset, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be a subset of another collection.
        /// The specification fails if the collection is not a subset of the other collection.
        /// Displays a message if the assertion fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset, string message, params object[] parameters) where T : ICollection
        {
            if (!IsSubsetOf(self.Value, superset))
            {
                Fail("ShouldBeSubsetOf", string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that a specified collection should not be a subset of another collection.
        /// The specification fails if the collection is a subset of the other collection.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        public static void ShouldNotBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset) where T : ICollection
        {
            ShouldNotBeSubsetOf(self, superset, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be a subset of another collection.
        /// The specification fails if the collection is a subset of the other collection.
        /// Displays a message if the assertion fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset, string message) where T : ICollection
        {
            ShouldNotBeSubsetOf(self, superset, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be a subset of another collection.
        /// The specification fails if the collection is a subset of the other collection.
        /// Displays a message if the assertion fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="superset">The collection that the specified collection should be
        /// a subset of.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeSubsetOf<T>(this SpecificationValue<T> self,
            ICollection superset, string message, params object[] parameters) where T : ICollection
        {
            if (IsSubsetOf(self.Value, superset))
            {
                Fail("ShouldNotBeSubsetOf", string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that a specified collection should contain a specified object.
        /// The specification fails if the collection does not contain the specified
        /// object.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        public static void ShouldContain<T>(this SpecificationValue<T> self, object expected) where T : ICollection
        {
            ShouldContain(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should contain a specified object.
        /// The specification fails if the collection does not contain the specified
        /// object. Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldContain<T>(this SpecificationValue<T> self, object expected, string message) where T : ICollection
        {
            ShouldContain(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should contain a specified object.
        /// The specification fails if the collection does not contain the specified
        /// object. Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldContain<T>(this SpecificationValue<T> self, object expected, string message, params object[] parameters) where T : ICollection
        {
            ICollection actual = self.Value;
            foreach (object item in actual)
            {
                if (item.Equals(expected))
                    return;
            }
            Fail("ShouldContain", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified collection should not contain a specified object.
        /// The specification fails if the collection does contain the specified
        /// object.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        public static void ShouldNotContain<T>(this SpecificationValue<T> self, object expected) where T : ICollection
        {
            ShouldNotContain(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not contain a specified object.
        /// The specification fails if the collection does contain the specified
        /// object. Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotContain<T>(this SpecificationValue<T> self, object expected, string message) where T : ICollection
        {
            ShouldNotContain(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not contain a specified object.
        /// The specification fails if the collection does contain the specified
        /// object. Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The object that the specified collection should
        /// contain.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotContain<T>(this SpecificationValue<T> self, object expected, string message, params object[] parameters) where T : ICollection
        {
            ICollection actual = self.Value;
            foreach (object item in actual)
            {
                if (item.Equals(expected))
                    Fail("ShouldNotContain", string.Empty, message, parameters);
            }
        }

        /// <summary>
        /// Specifies that a specified collection should be equivalent to another
        /// collection. The specification fails if the collection does not contain the
        /// same items as the other collection, regardless of order.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// be equivalent to.</param>
        public static void ShouldBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected) where T : ICollection
        {
            ShouldBeEquivalent(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be equivalent to another
        /// collection. The specification fails if the collection does not contain the
        /// same items as the other collection, regardless of order. Displays a
        /// message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// be equivalent to.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected, string message) where T : ICollection
        {
            ShouldBeEquivalent(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be equivalent to another
        /// collection. The specification fails if the collection does not contain the
        /// same items as the other collection, regardless of order. Displays a
        /// message if the specification fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// be equivalent to.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected, string message, params object[] parameters) where T : ICollection
        {
            ICollection actual = self.Value;
            if ((expected == null) != (actual == null))
            {
                Fail("ShouldBeEquivalent", string.Empty, message, parameters);
            }

            if (!object.ReferenceEquals(expected, actual) && (expected != null))
            {
                if (expected.Count != actual.Count)
                {
                    Fail("ShouldBeEquivalent", string.Empty, message, parameters);
                }

                int actualOccurrences;
                int expectedOccurrences;
                object mismatchedObject;
                if ((expected.Count != 0) &&
                    FindMismatchedElement(actual, expected, out actualOccurrences,
                    out expectedOccurrences, out mismatchedObject))
                {
                    Fail("ShouldBeEquivalent", string.Empty, message, parameters);
                }
            }
        }

        /// <summary>
        /// Specifies that a specified collection should not be equivalent to another
        /// collection. The specification fails if the collection does contain the
        /// same items as the other collection, regardless of order.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// not be equivalent to.</param>
        public static void ShouldNotBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected) where T : ICollection
        {
            ShouldNotBeEquivalent(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be equivalent to another
        /// collection. The specification fails if the collection does contain the
        /// same items as the other collection, regardless of order. Displays a
        /// message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// not be equivalent to.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected, string message) where T : ICollection
        {
            ShouldNotBeEquivalent(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be equivalent to another
        /// collection. The specification fails if the collection does contain the
        /// same items as the other collection, regardless of order. Displays a
        /// message if the specification fails, and applies the specified formatting
        /// to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="expected">The collection that the specified collection should
        /// not be equivalent to.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeEquivalent<T>(this SpecificationValue<T> self, ICollection expected, string message, params object[] parameters) where T : ICollection
        {
            ICollection actual = self.Value;
            if ((expected == null) == (actual == null))
            {
                if (object.ReferenceEquals(expected, actual))
                {
                    Fail("ShouldNotBeEquivalent",
                        string.Empty, message, parameters);
                }
                if (expected.Count == actual.Count)
                {
                    int actualOccurrences;
                    int expectedOccurrences;
                    object mismatchedObject;
                    if (expected.Count == 0)
                    {
                        Fail("ShouldNotBeEquivalent",
                            string.Empty, message, parameters);
                    }
                    if (!FindMismatchedElement(actual, expected, out actualOccurrences,
                        out expectedOccurrences, out mismatchedObject))
                    {
                        Fail("ShouldNotBeEquivalent",
                            string.Empty, message, parameters);
                    }
                }
            }
        }

        /// <summary>
        /// Specifies that a specified collection should be empty. The specification
        /// fails if the collection contains any items.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        public static void ShouldBeEmpty<T>(this SpecificationValue<T> self) where T : ICollection
        {
            ShouldBeEmpty(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be empty. The specification
        /// fails if the collection contains any items. Displays a message if the
        /// specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeEmpty<T>(this SpecificationValue<T> self, string message) where T : ICollection
        {
            ShouldBeEmpty(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should be empty. The specification
        /// fails if the collection contains any items. Displays a message if the
        /// specification fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeEmpty<T>(this SpecificationValue<T> self, string message, params object[] parameters) where T : ICollection
        {
            if (self.Value.Count > 0)
                Fail("ShouldBeEmpty", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified collection should not be empty. The specification
        /// fails if the collection does not contain any items.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        public static void ShouldNotBeEmpty<T>(this SpecificationValue<T> self) where T : ICollection
        {
            ShouldNotBeEmpty(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be empty. The specification
        /// fails if the collection does not contain any items. Displays a message if the
        /// specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeEmpty<T>(this SpecificationValue<T> self, string message) where T : ICollection
        {
            ShouldNotBeEmpty(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified collection should not be empty. The specification
        /// fails if the collection does not contain any items. Displays a message if the
        /// specification fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped collection to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeEmpty<T>(this SpecificationValue<T> self, string message, params object[] parameters) where T : ICollection
        {
            if (self.Value.Count == 0)
                Fail("ShouldNotBeEmpty", string.Empty, message, parameters);
        }

        #endregion

        #region String specifications

        /// <summary>
        /// Specifies that a specified string should contain another string. The
        /// specification fails if the string does not contain the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        public static void ShouldContain(this SpecificationValue<string> self, string expected)
        {
            ShouldContain(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should contain another string. The
        /// specification fails if the string does not contain the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldContain(this SpecificationValue<string> self, string expected, string message)
        {
            ShouldContain(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should contain another string. The
        /// specification fails if the string does not contain the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldContain(this SpecificationValue<string> self, string expected, string message, params object[] parameters)
        {
            string actual = self.Value;
            if (actual.IndexOf(expected, StringComparison.CurrentCulture) < 0)
                Fail("ShouldContain", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not contain another string. The
        /// specification fails if the string does contain the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        public static void ShouldNotContain(this SpecificationValue<string> self, string expected)
        {
            ShouldNotContain(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not contain another string. The
        /// specification fails if the string does contain the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotContain(this SpecificationValue<string> self, string expected, string message)
        {
            ShouldNotContain(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not contain another string. The
        /// specification fails if the string does contain the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected substring to find in the
        /// specified string.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotContain(this SpecificationValue<string> self, string expected, string message, params object[] parameters)
        {
            string actual = self.Value;
            if (actual.IndexOf(expected, StringComparison.CurrentCulture) >= 0)
                Fail("ShouldNotContain", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should start with another string. The
        /// specification fails if the string does not start with the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should start with.</param>
        public static void ShouldStartWith(this SpecificationValue<string> self, string substring)
        {
            ShouldStartWith(self, substring, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should start with another string. The
        /// specification fails if the string does not start with the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should start with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldStartWith(this SpecificationValue<string> self, string substring, string message)
        {
            ShouldStartWith(self, substring, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should start with another string. The
        /// specification fails if the string does not start with the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should start with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldStartWith(this SpecificationValue<string> self, string substring, string message, params object[] parameters)
        {
            string value = self.Value;
            if (!value.StartsWith(substring, StringComparison.CurrentCulture))
                Fail("ShouldStartWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not start with another string.
        /// The specification fails if the string does start with the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not start with.</param>
        public static void ShouldNotStartWith(this SpecificationValue<string> self, string substring)
        {
            ShouldNotStartWith(self, substring, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not start with another string.
        /// The specification fails if the string does start with the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not start with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotStartWith(this SpecificationValue<string> self, string substring, string message)
        {
            ShouldNotStartWith(self, substring, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not start with another string.
        /// The specification fails if the string does start with the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not start with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotStartWith(this SpecificationValue<string> self, string substring, string message, params object[] parameters)
        {
            string value = self.Value;
            if (value.StartsWith(substring, StringComparison.CurrentCulture))
                Fail("ShouldStartWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should end with another string. The
        /// specification fails if the string does not end with the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should end with.</param>
        public static void ShouldEndWith(this SpecificationValue<string> self, string substring)
        {
            ShouldEndWith(self, substring, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should end with another string. The
        /// specification fails if the string does not end with the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should end with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldEndWith(this SpecificationValue<string> self, string substring, string message)
        {
            ShouldEndWith(self, substring, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should end with another string. The
        /// specification fails if the string does not end with the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should end with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldEndWith(this SpecificationValue<string> self, string substring, string message, params object[] parameters)
        {
            string value = self.Value;
            if (!value.EndsWith(substring, StringComparison.CurrentCulture))
                Fail("ShouldEndWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not end with another string. The
        /// specification fails if the string does end with the other string.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not end with.</param>
        public static void ShouldNotEndWith(this SpecificationValue<string> self, string substring)
        {
            ShouldNotEndWith(self, substring, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not end with another string. The
        /// specification fails if the string does end with the other string.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not end with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotEndWith(this SpecificationValue<string> self, string substring, string message)
        {
            ShouldNotEndWith(self, substring, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not end with another string. The
        /// specification fails if the string does end with the other string.
        /// Displays a message if the specification fails, and applies the
        /// specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string  specified string
        /// should not end with.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotEndWith(this SpecificationValue<string> self, string substring, string message, params object[] parameters)
        {
            string value = self.Value;
            if (value.EndsWith(substring, StringComparison.CurrentCulture))
                Fail("ShouldEndWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should equal another string, ignoring
        /// case. The specification fails if the string does not equal the other string,
        /// regardless of case.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should equal.</param>
        public static void ShouldEqualIgnoringCase(this SpecificationValue<string> self, string expected)
        {
            ShouldEqualIgnoringCase(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should equal another string, ignoring
        /// case. The specification fails if the string does not equal the other string,
        /// regardless of case. Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should equal.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldEqualIgnoringCase(this SpecificationValue<string> self, string expected, string message)
        {
            ShouldEqualIgnoringCase(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should equal another string, ignoring
        /// case. The specification fails if the string does not equal the other string,
        /// regardless of case. Displays a message if the specification fails, and
        /// applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should equal.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldEqualIgnoringCase(this SpecificationValue<string> self, string expected, string message, params object[] parameters)
        {
            string actual = self.Value;
            if (!actual.Equals(expected, StringComparison.CurrentCultureIgnoreCase))
                Fail("ShouldEndWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not equal another string, ignoring
        /// case. The specification fails if the string does equal the other string,
        /// regardless of case.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should not equal.</param>
        public static void ShouldNotEqualIgnoringCase(this SpecificationValue<string> self, string expected)
        {
            ShouldNotEqualIgnoringCase(self, expected, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not equal another string, ignoring
        /// case. The specification fails if the string does equal the other string,
        /// regardless of case. Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should not equal.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotEqualIgnoringCase(this SpecificationValue<string> self, string expected, string message)
        {
            ShouldNotEqualIgnoringCase(self, expected, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not equal another string, ignoring
        /// case. The specification fails if the string does equal the other string,
        /// regardless of case. Displays a message if the specification fails, and
        /// applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected string the specified string
        /// should not equal.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotEqualIgnoringCase(this SpecificationValue<string> self, string expected, string message, params object[] parameters)
        {
            string actual = self.Value;
            if (actual.Equals(expected, StringComparison.CurrentCultureIgnoreCase))
                Fail("ShouldEndWith", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should match a regular expression pattern.
        /// The specification fails if the string does not match the regular expression.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should match.</param>
        public static void ShouldMatch(this SpecificationValue<string> self, Regex pattern)
        {
            ShouldMatch(self, pattern, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should match a regular expression pattern.
        /// The specification fails if the string does not match the regular expression.
        /// Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should match.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldMatch(this SpecificationValue<string> self, Regex pattern, string message)
        {
            ShouldMatch(self, pattern, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should match a regular expression pattern.
        /// The specification fails if the string does not match the regular expression.
        /// Displays a message if the specification fails, and applies the specified
        /// formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should match.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldMatch(this SpecificationValue<string> self, Regex pattern, string message, params object[] parameters)
        {
            if (!pattern.Match(self.Value).Success)
                Fail("ShouldMatch", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not match a regular expression
        /// pattern. The specification fails if the string does match the regular
        /// expression.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should not match.</param>
        public static void ShouldNotMatch(this SpecificationValue<string> self, Regex pattern)
        {
            ShouldNotMatch(self, pattern, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not match a regular expression
        /// pattern. The specification fails if the string does match the regular
        /// expression. Displays a message if the specification fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should not match.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotMatch(this SpecificationValue<string> self, Regex pattern, string message)
        {
            ShouldNotMatch(self, pattern, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not match a regular expression
        /// pattern. The specification fails if the string does match the regular
        /// expression. Displays a message if the specification fails, and applies
        /// the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="expected">The expected pattern the specified string
        /// should not match.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotMatch(this SpecificationValue<string> self, Regex pattern, string message, params object[] parameters)
        {
            if (pattern.Match(self.Value).Success)
                Fail("ShouldMatch", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should be empty. The specification
        /// fails if the string is not empty.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        public static void ShouldBeEmpty(this SpecificationValue<string> self)
        {
            ShouldBeEmpty(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should be empty. The specification
        /// fails if the string is not empty. Displays a message if the specification
        /// fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldBeEmpty(this SpecificationValue<string> self, string message)
        {
            ShouldBeEmpty(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should be empty. The specification
        /// fails if the string is not empty. Displays a message if the specification
        /// fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldBeEmpty(this SpecificationValue<string> self, string message, params object[] parameters)
        {
            if (self.Value.Length > 0)
                Fail("ShouldBeEmpty", string.Empty, message, parameters);
        }

        /// <summary>
        /// Specifies that a specified string should not be empty. The specification
        /// fails if the string is empty.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        public static void ShouldNotBeEmpty(this SpecificationValue<string> self)
        {
            ShouldNotBeEmpty(self, string.Empty, null);
        }

        /// <summary>
        /// Specifies that a specified string should not be empty. The specification
        /// fails if the string is empty. Displays a message if the specification
        /// fails.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        public static void ShouldNotBeEmpty(this SpecificationValue<string> self, string message)
        {
            ShouldNotBeEmpty(self, message, null);
        }

        /// <summary>
        /// Specifies that a specified string should not be empty. The specification
        /// fails if the string is empty. Displays a message if the specification
        /// fails, and applies the specified formatting to it.
        /// </summary>
        /// <param name="self">The <see cref="SpecificationValue&lt;T&tg;"/>
        /// wrapped string to check.</param>
        /// <param name="message">A message to display if the assertion fails. This message
        /// can be seen in the unit test results.</param>
        /// <param name="parameters">An array of parameters to use when formatting message.</param>
        public static void ShouldNotBeEmpty(this SpecificationValue<string> self, string message, params object[] parameters)
        {
            if (self.Value.Length == 0)
                Fail("ShouldNotBeEmpty", string.Empty, message, parameters);
        }

        #endregion

        #region Private/Internal implementation

        internal static void Fail(string specificationName, string message, string userMessage, params object[] parameters)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(FrameworkMessages.SpecificationFailed(specificationName));
            if (!string.IsNullOrEmpty(message))
            {
                builder.AppendFormat(CultureInfo.CurrentCulture, " {0}", message);
            }
            if (!string.IsNullOrEmpty(userMessage))
            {
                builder.Append(" ");
                builder.AppendFormat(CultureInfo.CurrentCulture,
                    ReplaceNulls(userMessage), parameters);
            }
            throw new AssertFailedException(builder.ToString());
        }

        private static string ReplaceNulls(object input)
        {
            if (input == null)
            {
                return FrameworkMessages.NullInMessages();
            }
            string str = input.ToString();
            if (str == null)
            {
                return FrameworkMessages.NullInMessages();
            }
            return ReplaceNullChars(str);
        }

        private static string ReplaceNullChars(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return input;
            }

            List<int> list = new List<int>();
            for (int i = 0; i < input.Length; ++i)
            {
                if (input[i] == '\0')
                {
                    list.Add(i);
                }
            }
            if (list.Count <= 0)
            {
                return input;
            }

            StringBuilder builder = new StringBuilder(input.Length + list.Count);
            int startIndex = 0;
            foreach (int index in list)
            {
                builder.Append(input.Substring(startIndex, index - startIndex));
                builder.Append(@"\0");
                startIndex = index + 1;
            }
            builder.Append(input.Substring(startIndex));
            return builder.ToString();
        }

        private class ObjectComparer : IComparer
        {
            #region IComparer Members

            public int Compare(object x, object y)
            {
                if (!object.Equals(x, y))
                {
                    return -1;
                }
                return 0;
            }

            #endregion
        }

        private static bool IsSubsetOf(ICollection subset, ICollection superset)
        {
            int subsetNullCount;
            int supersetNullCount;
            Dictionary<object, int> subsetCounts = GetElementCounts(subset, out subsetNullCount);
            Dictionary<object, int> supersetCounts = GetElementCounts(superset, out supersetNullCount);
            if (subsetNullCount > supersetNullCount)
            {
                return false;
            }
            foreach (object obj in subsetCounts.Keys)
            {
                int subsetCount;
                int supersetCount;
                subsetCounts.TryGetValue(obj, out subsetCount);
                supersetCounts.TryGetValue(obj, out supersetCount);
                if (subsetCount > supersetCount)
                {
                    return false;
                }
            }
            return true;
        }

        internal static bool FindMismatchedElement(ICollection actual, ICollection expected, out int actualCount, out int expectedCount, out object mismatchedElement)
        {
            int expectedNullCount;
            int actualNullCount;
            Dictionary<object, int> expectedElementCounts = GetElementCounts(expected, out expectedNullCount);
            Dictionary<object, int> actualElementCounts = GetElementCounts(actual, out actualNullCount);
            if (expectedNullCount != actualNullCount)
            {
                expectedCount = expectedNullCount;
                actualCount = actualNullCount;
                mismatchedElement = null;
                return true;
            }
            foreach (object obj in expectedElementCounts.Keys)
            {
                expectedElementCounts.TryGetValue(obj, out expectedCount);
                actualElementCounts.TryGetValue(obj, out actualCount);
                if (expectedCount != actualCount)
                {
                    mismatchedElement = obj;
                    return true;
                }
            }
            expectedCount = actualCount = 0;
            mismatchedElement = null;
            return false;
        }

        private static Dictionary<object, int> GetElementCounts(ICollection collection, out int nullCount)
        {
            Dictionary<object, int> dictionary = new Dictionary<object, int>();
            nullCount = 0;
            foreach (object obj in collection)
            {
                int num;
                if (obj == null)
                {
                    ++nullCount;
                    continue;
                }
                dictionary.TryGetValue(obj, out num);
                ++num;
                dictionary[obj] = num;
            }
            return dictionary;
        }

        private static bool AreCollectionsEqual(ICollection actual, ICollection expected, IComparer comparer, ref string reason)
        {
            if (!object.ReferenceEquals(expected, actual))
            {
                if ((expected == null) || (actual == null))
                {
                    return false;
                }
                if (expected.Count != actual.Count)
                {
                    reason = FrameworkMessages.DifferentNumberOfElements();
                    return false;
                }
                IEnumerator enumerator = expected.GetEnumerator();
                IEnumerator enumerator2 = actual.GetEnumerator();
                for (int i = 0; enumerator.MoveNext() && enumerator2.MoveNext(); i++)
                {
                    if (0 != comparer.Compare(enumerator.Current, enumerator2.Current))
                    {
                        reason = FrameworkMessages.ElementsDoNotMatch(i);
                        return false;
                    }
                }
                reason = FrameworkMessages.ElementsMatch();
                return true;
            }
            reason = FrameworkMessages.SameCollections();
            return true;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

William E. Kempf
Web Developer
United States United States
Windows developer with 10+ years experience working in the banking industry.

| Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 21 Dec 2007
Article Copyright 2007 by William E. Kempf
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid