Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

New Post: CollectionPropertyAssertions

$
0
0

Sorry, but example from my side. Here is a new one (but actually I don't see big difference between CollectionsAssertions and CollectionPropertyAssertions):

    public static class AssertionExtensions
    {
        public static CollectionPropertyAssertions<T> ShouldHave<T>(this IEnumerable<T> actual)
        {
            return new CollectionPropertyAssertions<T>(actual);
        }
    }

    public class CollectionPropertyAssertions<T>
    {
        private readonly IEnumerable<T> _actual;

        private bool _allProperties;

        public CollectionPropertyAssertions(IEnumerable<T> actual)
        {
            _actual = actual;
        }

        public CollectionPropertyAssertions<T> AllProperties()
        {
            _allProperties = true;
            return this;
        }

        public void EqualTo(IEnumerable<T> expected)
        {
            return;
        }
    }

    public class MainClass
    {
        public static void Main()
        {
            var actual = new List<int>() { 1, 2, 3 };
            actual.ShouldHave().AllProperties().EqualTo(new List<int>() { 1, 2, 3 });
        }
    }

Viewing all articles
Browse latest Browse all 1402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>