コード例 #1
0
        public IGen <Test> ItRendersOneLine() =>
        from value in Gen.Choose(DomainGen.Any(), DomainGen.AnyList())
        select Property.ForThese(() =>
        {
            var rendering = ExampleRenderer.Render(new object[] { value });

            rendering.Should().ContainSingle();
        });
コード例 #2
0
        public IGen <Test> IfKIsOne_ItProducesAListOfEachSingleElement() =>
        from list in DomainGen.AnyList().WithCountGreaterThanEqual(2)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.OtherCombinations <object>(1);

            var shrinks = func(list.ToList());

            shrinks.Should().HaveCount(list.Count);
            shrinks.SelectMany(x => x).Should().BeEquivalentTo(list);
        });
コード例 #3
0
        public IGen <Test> IfListCountIsGreaterThanK_ItWillShrink() =>
        from k in Gen.Int32().Between(1, 20)
        from list in DomainGen.AnyList().WithCountGreaterThan(k)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.OtherCombinations <object>(k);

            var shrinks = func(list.ToList());

            shrinks.Should().NotBeEmpty();
        });
コード例 #4
0
        public IGen <Test> ItWillProducesShrinksThatCanRecreateTheOriginalList() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCountGreaterThanEqual((minLength + 1) * 2)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Bisect <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.SelectMany(x => x).Should().BeEquivalentTo(list.ToList());
        });
コード例 #5
0
        public IGen <Test> IfListLengthIsLessThanDoubleMinLength_ItWillNotShrink() =>
        from minLength in TestGen.MinLength(minMinLength: 1)
        from list in DomainGen.AnyList().WithCountLessThan(minLength * 2)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Bisect <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should().BeEmpty();
        });
コード例 #6
0
        public IGen <Test> IfListHasOneElement_ItWillNotShrink() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCount(1)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Bisect <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should().BeEmpty();
        });
コード例 #7
0
        public IGen <Test> ItWillProduceDistinctShrinks() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCountGreaterThan(minLength)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.DropOne <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should().OnlyHaveUniqueItems();
        });
コード例 #8
0
        public IGen <Test> ItWillProduceTwoShrinksOfSimilarLengths() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCountGreaterThanEqual((minLength + 1) * 2)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Bisect <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should().HaveCount(2);
            shrinks.First().Count.Should().BeCloseTo(shrinks.Skip(1).Single().Count, 1);
        });
コード例 #9
0
        public IGen <Test> ItRendersLikeUnary() =>
        from values in DomainGen.AnyList().WithCountGreaterThan(1)
        select Property.ForThese(() =>
        {
            var unaryRenderings = values.SelectMany((value, index) => ExampleRenderer
                                                    .Render(new object[] { value })
                                                    .Select(line => $"[{index}] = {line}"));

            var multiaryRendering = ExampleRenderer.Render(values.ToArray());

            multiaryRendering.Should().BeEquivalentTo(unaryRenderings);
        });
コード例 #10
0
        public IGen <Test> ItWillNotProduceShrinksLessThanMinimumLength() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCountGreaterThanEqual((minLength + 1) * 2)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Bisect <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should()
            .NotBeEmpty().And
            .OnlyContain(shrink => shrink.Count >= minLength);
        });
コード例 #11
0
        public IGen <Test> ItWillProduceAShrinkForEachElementInTheList() =>
        from minLength in TestGen.MinLength()
        from list in DomainGen.AnyList().WithCountGreaterThan(minLength)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.DropOne <object>(minLength);

            var shrinks = func(list.ToList());

            shrinks.Should()
            .NotBeEmpty().And
            .OnlyContain(shrink => shrink.Count == list.Count - 1);
        });