Beispiel #1
0
        public void FormResponseService_UpdateFormResponseValid_ResultValid()
        {
            //arrange
            FormBuild        formBuild = new FormBuild("Teste", DateTime.Now);
            IntFieldBuilder  intField  = new IntFieldBuilder("value_test", 5, 10, true);
            TextFieldBuilder textField = new TextFieldBuilder("text");

            formBuild.AddField(textField);
            formBuild.AddField(intField);

            FormResponse formResponse = new FormResponse(formBuild);

            IntFieldResponse intResponse = new IntFieldResponse(intField);

            intResponse.SetValue(10);

            TextFieldResponse textResponse = new TextFieldResponse(textField);

            textResponse.SetValue("valid");

            formResponse.AddField(intResponse);
            formResponse.AddField(textResponse);

            _repository.Update(formResponse);

            //act
            ValidationResult result = _service.Update(formResponse);

            //assert
            Assert.True(result.IsValid, "Formulário não está válido");
        }
        public ValidationResult Update(FormResponse formResponse)
        {
            ValidationResult result = formResponse.Validate();

            if (result.IsValid)
            {
                _repository.Update(formResponse);
            }

            return(result);
        }