예제 #1
0
        public void ShouldComplainIfOperableIsNotAlsoOfTypeIDeclaration()
        {
            var operableOnly = mocks.DynamicMock <IOperable <MyClass> >();

            Assert.Throws <ArgumentException>(() =>
            {
                OperableExtensions.With(operableOnly, x => x.StringOne = "test");
            });
        }
예제 #2
0
        public void ShouldComplainIfOperableIsNotAlsoOfTypeIDeclaration()
        {
            var operableOnly = Substitute.For <IOperable <MyClass> >();

            Should.Throw <ArgumentException>(() =>
            {
                OperableExtensions.With(operableOnly, x => x.StringOne = "test");
            });
        }
예제 #3
0
        public void ShouldBeAbleToUseWithToSetPrivateProperties()
        {
            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(new ObjectBuilder <MyClass>(null));
                objectBuilder.Expect(x => x.With(propertyExpression, 100));
            }

            OperableExtensions.With((IOperable <MyClass>)operable, propertyExpression, 100);
        }
예제 #4
0
        public void ShouldBeAbleToUseAnd()
        {
            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(new ObjectBuilder <MyClass>(null));
                objectBuilder.Expect(x => x.With(func));
            }

            OperableExtensions.And((IOperable <MyClass>)operable, func);
        }
예제 #5
0
        public void ShouldBeAbleToUseWith()
        {
            var builderSetup = new BuilderSettings();

            {
                operable.ObjectBuilder.Returns(new ObjectBuilder <MyClass>(null, builderSetup));
                objectBuilder.With(func);
            }

            OperableExtensions.With((IOperable <MyClass>)operable, func);
        }
예제 #6
0
        public void ShouldBeAbleToUseAndToSetPrivateProperties()
        {
            var builderSetup = new BuilderSettings();

            {
                operable.ObjectBuilder.Returns(new ObjectBuilder <MyClass>(null, builderSetup));
                objectBuilder.With(propertyExpression, 100);
            }

            OperableExtensions.And((IOperable <MyClass>)operable, propertyExpression, 100);
        }
예제 #7
0
        public void ShouldBeAbleToUseAndToAddAnAction()
        {
            Action <MyClass> action = x => x.DoSomething();


            {
                operable.ObjectBuilder.Returns(objectBuilder);
                objectBuilder.Do(action).Returns(objectBuilder);
            }

            OperableExtensions.And((IOperable <MyClass>)operable, action);
        }
예제 #8
0
        public void ShouldBeAbleToUseHasDoneToIt()
        {
            Action <MyClass, int> action = (x, y) => x.DoSomething();

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(objectBuilder);
                objectBuilder.Expect(x => x.Do(action)).Return(objectBuilder);
            }

            OperableExtensions.With((IOperable <MyClass>)operable, action);
        }
예제 #9
0
        public void ShouldBeAbleToUseAndWithAnIndex()
        {
            Action <MyClass, int> funcWithIndex = (x, idx) => x.StringOne = "String" + (idx + 5);

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(new ObjectBuilder <MyClass>(null));
                objectBuilder.Expect(x => x.With(funcWithIndex));
            }

            OperableExtensions.And((IOperable <MyClass>)operable, funcWithIndex);
        }
예제 #10
0
        public void ShouldBeAbleToUseHasDoneToIt()
        {
            Action <MyClass, int> action = (x, y) => x.DoSomething();


            {
                operable.ObjectBuilder.Returns(objectBuilder);
                objectBuilder.Do(action).Returns(objectBuilder);
            }

            OperableExtensions.With((IOperable <MyClass>)operable, action);
        }
        public void ShouldBeAbleToUseHas()
        {
            var builderSetup = new BuilderSetup();

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(new ObjectBuilder <MyClass>(null, builderSetup));
                objectBuilder.Expect(x => x.With(func));
            }

            OperableExtensions.Has((IOperable <MyClass>)operable, func);
        }
예제 #12
0
        public void ShouldBeAbleToUseAndToSetPrivateProperties()
        {
            var builderSetup = new BuilderSettings();

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(new ObjectBuilder <MyClass>(null, builderSetup));
                objectBuilder.Expect(x => x.With(propertyExpression, 100));
            }

            OperableExtensions.And((IOperable <MyClass>)operable, propertyExpression, 100);
        }
        public void ShouldBeAbleToUseAndToAddAnAction()
        {
            Action <MyClass> action = x => x.DoSomething();

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(objectBuilder);
                objectBuilder.Expect(x => x.Do(action)).Return(objectBuilder);
            }

            OperableExtensions.And((IOperable <MyClass>)operable, action);
        }
예제 #14
0
        public void ShouldBeAbleToUseWith_WithAnIndex()
        {
            var builderSetup = new BuilderSettings();
            Action <MyClass, int> funcWithIndex = (x, idx) => x.StringOne = "String" + (idx + 5);

            {
                operable.ObjectBuilder.Returns(new ObjectBuilder <MyClass>(null, builderSetup));
                objectBuilder.With(funcWithIndex);
            }

            OperableExtensions.With((IOperable <MyClass>)operable, funcWithIndex);
        }
        public void ShouldBeAbleToUseHasDoneToItForAll()
        {
            var simpleClasses = new List <SimpleClass>();
            Action <MyClass, SimpleClass> action = (x, y) => x.Add(y);

            using (mocks.Record())
            {
                operable.Expect(x => x.ObjectBuilder).Return(objectBuilder);
                objectBuilder.Expect(x => x.DoMultiple(action, simpleClasses)).Return(objectBuilder);
            }

            OperableExtensions.HasDoneToItForAll((IOperable <MyClass>)operable, action, simpleClasses);
        }
예제 #16
0
        public void ShouldBeAbleToUseHasDoneToItForAll()
        {
            var simpleClasses = new List <SimpleClass>();
            Action <MyClass, SimpleClass> action = (x, y) => x.Add(y);


            {
                operable.ObjectBuilder.Returns(objectBuilder);
                objectBuilder.DoMultiple(action, simpleClasses).Returns(objectBuilder);
            }

            OperableExtensions.DoForEach((IOperable <MyClass>)operable, action, simpleClasses);
        }
        public void ShouldComplainIfOperableIsNotAlsoOfTypeIDeclaration()
        {
            var operableOnly = mocks.DynamicMock <IOperable <MyClass> >();

            OperableExtensions.With(operableOnly, x => x.StringOne = "test");
        }