Adds a matching criterion to the structural equality comparer.
Namespace:
MbUnit.FrameworkAssembly: MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.610.0)
Syntax
| C# |
|---|
public void Add<TValue>( Accessor<T, TValue> accessor, IEqualityComparer<TValue> comparer ) |
| Visual Basic (Declaration) |
|---|
Public Sub Add(Of TValue) ( _ accessor As Accessor(Of T, TValue), _ comparer As IEqualityComparer(Of TValue) _ ) |
Parameters
- accessor
- Type: Gallio.Common..::.Accessor<(Of <(T, TValue>)>)
An accessor that gets a value from the tested object.
- comparer
- Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TValue>)>)
A comparer instance, or null to use the default one (Default).
Type Parameters
- TValue
- The type of the value returned by the accessor.
Remarks
The values returned by the accessor are compared by using the specified comparer object.
Examples
public class Foo { public int Value; } public class MyComparer : IEqualityComparer<int> { public bool Equals(int x, int y) { return x == y; } public int GetHashCode(int obj) { return obj; } } [TestFixture] public class FooTest { [Test] public void MyTest() { var foo1 = new Foo() { Value = 123 }; var foo2 = new Foo() { Value = 123 }; Assert.AreEqual(foo1, foo2, new StructuralEqualityComparer<Foo> { { x => x.Value, new MyComparer() }, }); } }
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentNullException | The specified accessor argument is a null reference. |
