public void Should_RunDiscovery(bool?shouldExecuteInfo, int?errorId, object errorModeBoxed, string path)
        {
            var commandScope = new NullableCommandScope <decimal>();

            commandScope.ExecutionCondition = !shouldExecuteInfo.HasValue
                ? (Predicate <decimal?>)null
                : m =>
            {
                return(shouldExecuteInfo.Value);
            };

            commandScope.ErrorId = errorId;

            commandScope.ErrorMode = (ErrorMode)errorModeBoxed;

            commandScope.Path = path;

            commandScope.ScopeId = 123;

            var discoveryContext = Substitute.For <IDiscoveryContext>();

            commandScope.ShouldDiscover(discoveryContext, context =>
            {
                context.Received().EnterScope <decimal>(Arg.Is(123));
            });
        }
        public void Should_NotRunValidation_When_NullableHasNoValue(bool?shouldExecuteInfo, int?errorId, object errorModeBoxed, string path)
        {
            var commandScope = new NullableCommandScope <decimal>();

            var executionCounter = 0;

            commandScope.ExecutionCondition = !shouldExecuteInfo.HasValue
                ? (Predicate <decimal?>)null
                : m =>
            {
                m.Should().BeNull();
                executionCounter++;

                return(shouldExecuteInfo.Value);
            };

            commandScope.ErrorId = errorId;

            commandScope.ErrorMode = (ErrorMode)errorModeBoxed;

            commandScope.Path = path;

            commandScope.ScopeId = 123;

            var validationContext = Substitute.For <IValidationContext>();

            commandScope.ShouldValidate(
                null,
                validationContext,
                shouldExecuteInfo,
                context =>
            {
            });

            validationContext.DidNotReceiveWithAnyArgs().EnterScope <decimal>(default, default);
        public void Should_RunValidation(bool?shouldExecuteInfo, int?errorId, object errorModeBoxed, string path)
        {
            var commandScope = new NullableCommandScope <decimal>();

            var model = (decimal?)667;

            var executionCounter = 0;

            commandScope.ExecutionCondition = !shouldExecuteInfo.HasValue
                ? (Predicate <decimal?>)null
                : m =>
            {
                m.Should().Be(model);
                executionCounter++;

                return(shouldExecuteInfo.Value);
            };

            commandScope.ErrorId = errorId;

            commandScope.ErrorMode = (ErrorMode)errorModeBoxed;

            commandScope.Path = path;

            commandScope.ScopeId = 123;

            var validationContext = Substitute.For <IValidationContext>();

            commandScope.ShouldValidate(
                model,
                validationContext,
                shouldExecuteInfo,
                context =>
            {
                context.Received().EnterScope(Arg.Is(123), Arg.Is(model));
            });

            executionCounter.Should().Be(shouldExecuteInfo.HasValue ? 1 : 0);
        }
        public void Should_Initialize_WithDefaultValues()
        {
            var commandScope = new NullableCommandScope <decimal>();

            commandScope.ShouldHaveDefaultValues();
        }
 public void Should_Initialize()
 {
     _ = new NullableCommandScope <decimal>();
 }