public void Services_Validate_Required_Failed() { FormPackage6.Core.DomainModel.Form.Form formModel = new FormPackage6.Core.DomainModel.Form.Form(); Field field = new Field() { FieldType = new FieldType() { Type = "TextBox" }, Name = "Text", Id = "0001", Value = String.Empty, Mandatory = true }; formModel.Fields = new List <Field>(); formModel.Fields.Add(field); IFormService formService = IoCContainer.GetInstance <IFormService>(); var result = formService.Validate(formModel, null); Assert.IsNotNull(result.Errors.FirstOrDefault(x => x.FieldId == field.Id && x.ErrorType == "require")); }
public void Services_UploadFiles_Failed() { FormPackage6.Core.DomainModel.Form.Form formModel = new FormPackage6.Core.DomainModel.Form.Form(); Field field = new Field() { FieldType = new FieldType() { Type = FormPackage6.Core.Alias.PropertyAlias.Upload }, Name = "Text", Id = "0001", Value = String.Empty, Mandatory = true }; formModel.Fields = new List <Field>(); formModel.Fields.Add(field); List <FileViewModel> uploadedFiles = new List <FileViewModel>(); var file = new Mock <HttpPostedFileBase>(); file.Setup(x => x.FileName).Returns("test.jpg"); file.Setup(x => x.ContentType).Returns("PDF"); FileViewModel fileModel = new FileViewModel() { file = file.Object, name = field.Id }; uploadedFiles.Add(fileModel); IFormService formService = IoCContainer.GetInstance <IFormService>(); formService.SaveUploadFiles(ref formModel, uploadedFiles); mediaService.Verify(x => x.Save(It.IsAny <IMedia>(), 0, true)); }
public void Services_Validate_Email_OK() { FormPackage6.Core.DomainModel.Form.Form formModel = new FormPackage6.Core.DomainModel.Form.Form(); Field field = new Field() { FieldType = new FieldType() { Type = FormPackage6.Core.Alias.PropertyAlias.Email }, Value = "*****@*****.**" }; formModel.Fields = new List <Field>(); formModel.Fields.Add(field); IFormService formService = IoCContainer.GetInstance <IFormService>(); var result = formService.Validate(formModel, null); Assert.AreEqual(result.Message, "success"); }
public void Services_Validate_Email_Failed() { FormPackage6.Core.DomainModel.Form.Form formModel = new FormPackage6.Core.DomainModel.Form.Form(); Field field = new Field() { FieldType = new FieldType() { Type = FormPackage6.Core.Alias.PropertyAlias.Email }, Name = "Email", Id = "0001", Value = "email.com" }; formModel.Fields = new List <Field>(); formModel.Fields.Add(field); IFormService formService = IoCContainer.GetInstance <IFormService>(); var result = formService.Validate(formModel, null); Assert.IsNotNull(result.Errors.FirstOrDefault(x => x.FieldId == field.Id && x.ErrorType == "format")); }
public void Services_Validate_Required_OK() { FormPackage6.Core.DomainModel.Form.Form formModel = new FormPackage6.Core.DomainModel.Form.Form(); Field field = new Field() { FieldType = new FieldType() { Type = "TextBox" }, Name = "Text", Id = "0001", Value = "Something", Mandatory = true }; formModel.Fields = new List <Field>(); formModel.Fields.Add(field); IFormService formService = IoCContainer.GetInstance <IFormService>(); var result = formService.Validate(formModel, null); Assert.AreEqual(result.Message, "success"); }