Beispiel #1
0
        private static ShrinkFunc <List <IExampleSpace <T> > > ShrinkTowardsLength(int length)
        {
            // If the value type is a collection, that is, this generator is building a "collection of collections",
            // it is "less complex" to order the inner collections by descending length. It also lets us find the
            // minimal shrink a lot more efficiently in some examples,
            // e.g. https://github.com/jlink/shrinking-challenge/blob/main/challenges/large_union_list.md

            return(ShrinkFunc.TowardsCountOptimized <IExampleSpace <T>, decimal>(length, exampleSpace =>
            {
                return -exampleSpace.Current.Distance;
            }));
        }
        public void Snapshots_TowardsCountOptimized()
        {
            var result = _fixture
                         .Scenarios
                         .Select(scenario =>
            {
                var func = ShrinkFunc.TowardsCountOptimized <int, int>(scenario.MinLength, x => x);

                var shrinks = func(scenario.List);

                return(new
                {
                    Input = scenario,
                    Output = shrinks
                });
            })
                         .ToList();

            Snapshot.Match(result);
        }