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(); });
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); });
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(); });
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()); });
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(); });
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(); });
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(); });
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); });
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); });
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); });
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); });