Exemple #1
0
        public override void Behavior(Action <PropertyBehavior <CustomizedPropertyShouldModel> > action)
        {
            var mock = new Mock <ISpecification <CustomizedPropertyShouldModel> >();

            Spec.Specify(mock.Object);
            mock.Setup(x => x.OnProperty(It.IsAny <PropertyBehavior <CustomizedPropertyShouldModel, string> >())).Callback <PropertyBehavior <CustomizedPropertyShouldModel, string> >(p =>
            {
                if (p.Name == nameof(CustomizedPropertyShouldModel.P1))
                {
                    action(p);
                }
            });
            _result = Spec.Finish();
        }
        public override void Behavior(Action <MethodFunctionBehavior <CustomizedMethodShouldModel, string, string> > action)
        {
            var mock = new Mock <ISpecification <CustomizedMethodShouldModel> >();

            Spec.Specify(mock.Object);
            mock.Setup(x => x.OnMethod(
                           It.IsAny <MethodFunctionBehavior <CustomizedMethodShouldModel, string, string> >()))
            .Callback <MethodFunctionBehavior <CustomizedMethodShouldModel, string, string> >(p =>
            {
                if (p.Name == nameof(CustomizedMethodShouldModel.Run))
                {
                    action(p);
                }
            });
            _result = Spec.Finish();
        }
Exemple #3
0
        public void WhenParameterAttributeIsHidden_ThenAdapterParameterDoesNotHaveHiddenAttribute()
        {
            var p     = ParamSettings.WithName("x");
            var pAtts = p.Attributes;

            Spec.SpecifyMethod()
            .WithFunctionSignature <int, int, int>(nameof(CustomizedParameterShouldModel.Sum), p);
            IAdapter <CustomizedParameterShouldModel> adapter = null;
            var attributeTester = new AttributeTester <ParameterInfo>(
                () => { },
                () => pAtts,
                () => adapter = Spec.Finish().Create(null),
                () => adapter.GetType().GetMethod(nameof(CustomizedParameterShouldModel.Sum)).GetParameters()[0],
                pi => pi.GetCustomAttributes());

            attributeTester.TestHidingAttribute();
        }
Exemple #4
0
 protected virtual IAdapter <CustomizedPropertyShouldModel> Finish(CustomizedPropertyShouldModel model) => Spec.Finish().Create(model);
Exemple #5
0
 void FinishType() => Adapter = Spec.Finish().Create(null);