public void NotShrinking()
        {
            Func <bool> runFunc =
                () =>
            {
                if (theInt == 42)
                {
                    return(true);                  // means failure
                }
                return(false);
            };

            theInt = 42;

            var shrinkStrat =
                new ShrinkingStrategy()
                .Add(Manipulate.This(this)
                     .Change(e => e.theInt, -1)
                     .Change(e => e.theInt, 0)
                     .Change(e => e.theInt, 1));

            shrinkStrat.Shrink(runFunc);

            Assert.False(shrinkStrat.Shrunk());
        }
示例#2
0
 public override void Shrink(Func <bool> runFunc)
 {
     shrunk =
         new ShrinkingStrategy()
         .Add(Manipulate.This(this)
              .Change(e => e.input, -1)
              .Change(e => e.input, 0)
              .Change(e => e.input, 1));
     shrunk.Shrink(runFunc);
 }
        public void Shrunk()
        {
            var something = Generate.One<SomethingToShrink>();
            something.IntProperty = 42;
            var composite =
                new ShrinkingStrategy()
                    .Add(-1, 0, 1)
                    .Ignore<SomethingToShrink, int>(e => e.IntProperty)
                    .RegisterAll(something);

            Assert.Throws<NullReferenceException>(() => composite.Shrunk(something, e => e.IntProperty));
        }
        public void Shrunk()
        {
            var something = Generate.One <SomethingToShrink>();

            something.IntProperty = 42;
            var composite =
                new ShrinkingStrategy()
                .Add(-1, 0, 1)
                .Ignore <SomethingToShrink, int>(e => e.IntProperty)
                .RegisterAll(something);

            Assert.Throws <NullReferenceException>(() => composite.Shrunk(something, e => e.IntProperty));
        }
        public void Shrunk()
        {
            var something = Generate.One<SomethingToShrink>();
            var composite =
                new ShrinkingStrategy()
                    .Add(-1, 0, 1, "")
                    .AddNull<string>()
                    .RegisterAll(something);

            composite.Shrink(() => true);

            Assert.True(composite.Shrunk());
            Assert.True(composite.Shrunk(something, e => e.IntProperty));
            Assert.True(composite.Shrunk(something, e => e.StringProperty));
        }
        public void NotShrunk()
        {
            var something = Generate.One <SomethingToShrink>();
            var composite =
                new ShrinkingStrategy()
                .Add(-1, 0, 1, "")
                .AddNull <string>()
                .RegisterAll(something);

            composite.Shrink(() => false);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.IntProperty));
            Assert.False(composite.Shrunk(something, e => e.StringProperty));
        }
        public void Shrunk()
        {
            var something = Generate.One<SomethingToShrink>();
            something.IntProperty = 42;
            var composite =
                new ShrinkingStrategy()
                    .Add(Simple.Values<int>())
                    .Add(Simple.Values<string>())
                    .RegisterAll(something);

            composite.Shrink(() => something.IntProperty == 42);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.IntProperty));
            Assert.True(composite.Shrunk(something, e => e.StringProperty));
        }
        public void SimpleShrinking()
        {
            Func<bool> runFunc = () => true; // means fail always

            theInt = 42;

            var shrinkStrat =
                new ShrinkingStrategy()
                    .Add(Manipulate.This(this)
                             .Change(e => e.theInt, -1)
                             .Change(e => e.theInt, 0)
                             .Change(e => e.theInt, 1));

            shrinkStrat.Shrink(runFunc);

            Assert.True(shrinkStrat.Shrunk());
        }
示例#9
0
        public void Shrunk()
        {
            var something = Generate.One <SomethingToShrink>();

            something.IntProperty = 42;
            var composite =
                new ShrinkingStrategy()
                .Add(Simple.AllValues())
                .Register(something, e => e.IntProperty)
                .Register(something, e => e.StringProperty);

            composite.Shrink(() => something.IntProperty == 42);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.IntProperty));
            Assert.True(composite.Shrunk(something, e => e.StringProperty));
        }
        public void SimpleShrinking()
        {
            Func <bool> runFunc = () => true; // means fail always

            theInt = 42;

            var shrinkStrat =
                new ShrinkingStrategy()
                .Add(Manipulate.This(this)
                     .Change(e => e.theInt, -1)
                     .Change(e => e.theInt, 0)
                     .Change(e => e.theInt, 1));

            shrinkStrat.Shrink(runFunc);

            Assert.True(shrinkStrat.Shrunk());
        }
示例#11
0
 public override void Shrink(Func <bool> runFunc)
 {
     shrinkA =
         new ShrinkingStrategy()
         .Add(Manipulate.This(this)
              .Change(e => e.a, -1)
              .Change(e => e.a, 0)
              .Change(e => e.a, 1));
     shrinkB =
         new ShrinkingStrategy()
         .Add(Manipulate.This(this)
              .Change(e => e.b, -1)
              .Change(e => e.b, 0)
              .Change(e => e.b, 1));
     shrinkA.Shrink(runFunc);
     shrinkB.Shrink(runFunc);
 }
        public void TwoOutOfThree()
        {
            var something =
                new SomethingToShrink
            {
                PropertyOne   = 42,
                PropertyTwo   = 42,
                PropertyThree = 42,
            };
            var composite =
                new ShrinkingStrategy()
                .Add(Simple.AllValues())
                .RegisterAll(something);

            composite.Shrink(() => something.PropertyOne == 42 && something.PropertyTwo == 42);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.PropertyOne));
            Assert.False(composite.Shrunk(something, e => e.PropertyTwo));
            Assert.True(composite.Shrunk(something, e => e.PropertyThree));
        }
        public void TwoOutOfThree()
        {
            var something =
                new SomethingToShrink
                    {
                        PropertyOne = 42,
                        PropertyTwo = 42,
                        PropertyThree = 42,
                    };
            var composite =
                new ShrinkingStrategy()
                    .Add(Simple.AllValues())
                    .RegisterAll(something);

            composite.Shrink(() => something.PropertyOne == 42 && something.PropertyTwo == 42);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.PropertyOne));
            Assert.False(composite.Shrunk(something, e => e.PropertyTwo));
            Assert.True(composite.Shrunk(something, e => e.PropertyThree));
        }
        public void NotShrinking()
        {
            Func<bool> runFunc =
                () =>
                {
                    if (theInt == 42) return true; // means failure
                    return false;
                };

            theInt = 42;

            var shrinkStrat =
                new ShrinkingStrategy()
                    .Add(Manipulate.This(this)
                             .Change(e => e.theInt, -1)
                             .Change(e => e.theInt, 0)
                             .Change(e => e.theInt, 1));

            shrinkStrat.Shrink(runFunc);

            Assert.False(shrinkStrat.Shrunk());
        }