private XsdElementFault CreateXsdElementFault() { XsdElementFault fault = Store.ElementFactory.CreateElement(XsdElementFault.DomainClassId) as XsdElementFault; fault.Name = "foo"; return(fault); }
public override void ElementAdded(ElementAddedEventArgs e) { XsdElementFault fault = e.ModelElement as XsdElementFault; if (fault.Operation != null) { ServiceContractModel root = fault.Operation.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(fault, root.ImplementationTechnology); } } }
public void ReturnSuccessForValidSerializer() { Operation operation = CreateOperation(); XsdElementFault fault = CreateXsdElementFault(); operation.ServiceContractModel.SerializerType = SerializerType.DataContractSerializer; operation.Faults.Add(fault); TestXsdElementFaultCollectionValidator validator = new TestXsdElementFaultCollectionValidator(); ValidationResults validationResults = new ValidationResults(); validator.TestDoValidate(operation.Faults, operation, "", validationResults); Assert.IsTrue(validationResults.IsValid); }
protected override void DoValidate(IEnumerable <Fault> objectToValidate, object currentTarget, string key, ValidationResults validationResults) { foreach (Fault item in objectToValidate) { XsdElementFault xsdElementFault = item as XsdElementFault; if (xsdElementFault != null) { if (xsdElementFault.Operation.ServiceContractModel.SerializerType == SerializerType.XmlSerializer) { validationResults.AddResult( new ValidationResult(String.Format(CultureInfo.CurrentUICulture, this.MessageTemplate, xsdElementFault.Operation.Name, xsdElementFault.Name), objectToValidate, key, String.Empty, this) ); } } } }