public void GivenEmptySurveyOptions_WhenValidatingCommand_ThenIsValidShouldBeFalse()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>());

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.Should().BeFalse();
            result.Errors.Should().Contain(error => error.PropertyName == nameof(CreateSurveyCommand.SurveyOptions));
        }
        public void IsValid_ShouldBeFalse_WhenSurveyOptionsAreEmpty()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>());

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(false);
            result.Errors.ShouldContain(error => error.PropertyName == nameof(CreateSurveyCommand.SurveyOptions));
        }
        public void GivenEmptySurveyOptionText_WhenValidatingCommand_ThenIsValidShouldBeFalse()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText = ""
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.Should().BeFalse();
            result.Errors.Should().Contain(error => error.PropertyName == "SurveyOptions[0].OptionText");
        }
        public void GivenValidCreateSurveyCommand_WhenValidatingCommand_ThenIsValidShouldBeTrue()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText             = "Test",
                    PreferredNumberOfVotes = 1
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.Should().BeTrue();
        }
        public void IsValid_ShouldBeFalse_WhenSurveyOptionTextIsEmpty()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText = ""
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(false);
            result.Errors.ShouldContain(error => error.PropertyName == "SurveyOptions[0].OptionText");
        }
        public void IsValid_ShouldBeTrue_WhenValidValuesAreSpecified()
        {
            var command = new CreateSurveyCommand("Test", 1, "Test", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText             = "Test",
                    PreferredNumberOfVotes = 1
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(true);
        }
        public void GivenEmptyRespondentType_WhenValidatingCommand_ThenIsValidShouldBeFalse()
        {
            var command = new CreateSurveyCommand("Test", 1, "", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText             = "Test",
                    PreferredNumberOfVotes = 1
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.Should().BeFalse();
            result.Errors.Should().Contain(error => error.PropertyName == nameof(CreateSurveyCommand.RespondentType));
        }
        public void IsValid_ShouldBeFalse_WhenRespondentTypeIsNotSpecified()
        {
            var command = new CreateSurveyCommand("Test", 1, "", new List <SurveyOptionDto>
            {
                new SurveyOptionDto
                {
                    OptionText             = "Test",
                    PreferredNumberOfVotes = 1
                }
            });

            var validator = new CreateSurveyCommandValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(false);
            result.Errors.ShouldContain(error => error.PropertyName == nameof(CreateSurveyCommand.RespondentType));
        }