Make it possible for third-party libraries to access the underlying collection of instances of `ReadOnlyNonGenericCollectionWrapper` by logiclrd · Pull Request #1968 · fluentassertions/fluentassertions · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Src/FluentAssertions/Common/ICollectionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static ReadOnlyNonGenericCollectionWrapper<DataRowCollection, DataRow> Cr
}
}

internal class ReadOnlyNonGenericCollectionWrapper<TCollection, TItem> : ICollection<TItem>
internal class ReadOnlyNonGenericCollectionWrapper<TCollection, TItem> : ICollection<TItem>, ICollectionWrapper<TCollection>
where TCollection : ICollection
{
public TCollection UnderlyingCollection { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> BeSameAs(
Guard.ThrowIfArgumentIsNull(
expected, nameof(expected), "Cannot verify same reference against a <null> collection (use BeNull instead?).");

if (assertion.Subject is ReadOnlyNonGenericCollectionWrapper<DataColumnCollection, DataColumn> wrapper)
if (assertion.Subject is ICollectionWrapper<DataColumnCollection> wrapper)
{
var actualSubject = wrapper.UnderlyingCollection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ namespace FluentAssertions.Common
System.Threading.Tasks.Task DelayAsync(System.TimeSpan delay, System.Threading.CancellationToken cancellationToken);
FluentAssertions.Common.ITimer StartTimer();
}
public interface ICollectionWrapper<TCollection>
where TCollection : System.Collections.ICollection
{
TCollection UnderlyingCollection { get; }
}
public interface IConfigurationStore
{
string GetSetting(string name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@ namespace FluentAssertions.Common
System.Threading.Tasks.Task DelayAsync(System.TimeSpan delay, System.Threading.CancellationToken cancellationToken);
FluentAssertions.Common.ITimer StartTimer();
}
public interface ICollectionWrapper<TCollection>
where TCollection : System.Collections.ICollection
{
TCollection UnderlyingCollection { get; }
}
public interface IConfigurationStore
{
string GetSetting(string name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ namespace FluentAssertions.Common
System.Threading.Tasks.Task DelayAsync(System.TimeSpan delay, System.Threading.CancellationToken cancellationToken);
FluentAssertions.Common.ITimer StartTimer();
}
public interface ICollectionWrapper<TCollection>
where TCollection : System.Collections.ICollection
{
TCollection UnderlyingCollection { get; }
}
public interface IConfigurationStore
{
string GetSetting(string name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ namespace FluentAssertions.Common
System.Threading.Tasks.Task DelayAsync(System.TimeSpan delay, System.Threading.CancellationToken cancellationToken);
FluentAssertions.Common.ITimer StartTimer();
}
public interface ICollectionWrapper<TCollection>
where TCollection : System.Collections.ICollection
{
TCollection UnderlyingCollection { get; }
}
public interface IConfigurationStore
{
string GetSetting(string name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ namespace FluentAssertions.Common
System.Threading.Tasks.Task DelayAsync(System.TimeSpan delay, System.Threading.CancellationToken cancellationToken);
FluentAssertions.Common.ITimer StartTimer();
}
public interface ICollectionWrapper<TCollection>
where TCollection : System.Collections.ICollection
{
TCollection UnderlyingCollection { get; }
}
public interface IConfigurationStore
{
string GetSetting(string name);
Expand Down