Skip to content

Commit

Permalink
Added interface ICollectionWrapper<TCollection> to expose the Underly…
Browse files Browse the repository at this point in the history
…ingCollection property of ReadOnlyNonGenericCollectionWrapper<TCollection, TItem>.

Updated the ReadOnlyNonGenericCollectionWrapper<TCollection, TItem> type to implement ICollectionWrapper<TCollection>.
Updated DataColumnCollectionAssertionExtensions.cs to access UnderlyingCollection via ICollectionWrapper instead of the concrete type ReadOnlyNonGenericCollectionWrapper.
Updated the exposed API surface files correspondingly.
  • Loading branch information
logiclrd committed Aug 10, 2022
1 parent de9faf3 commit 7708660
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Src/FluentAssertions/Common/ICollectionWrapper.cs
@@ -0,0 +1,15 @@
using System.Collections;

namespace FluentAssertions.Common
{
/// <summary>
/// Used to provide access to the underlying <typeparamref name="TCollection"/> for an object that wraps an underlying
/// collection.
/// </summary>
/// <typeparam name="TCollection">Collection type.</typeparam>
public interface ICollectionWrapper<TCollection>
where TCollection : ICollection
{
TCollection UnderlyingCollection { get; }
}
}
Expand Up @@ -33,7 +33,7 @@ internal static class ReadOnlyNonGenericCollectionWrapper
}
}

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
Expand Up @@ -30,7 +30,7 @@ public static class DataColumnCollectionAssertionExtensions
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
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
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
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
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
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
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

0 comments on commit 7708660

Please sign in to comment.