public virtual void TestEverythingSpecified() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.SimpleValue = "simple text value"; codedType.Operator = SetOperator.CONVEX_HULL; codedType.Value = BigDecimal.ONE; codedType.Translation.Add(new CodedTypeR2 <Code>()); codedType.Qualifier.Add(new CodeRole()); EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "original text not allowed for SC"; codedType.OriginalText = originalText; SC_R2 <Code> sc = new SC_R2Impl <Code>(codedType); string result = new ScR2PropertyFormatter().Format(GetContext("name", "SC"), sc); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(5, this.result.GetHl7Errors().Count); Assert.AreEqual("<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\">simple text value</name>" , StringUtils.Trim(result), "result"); }
public virtual void TestOriginalTextAndNullFlavor() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "original text not allowed for SC"; codedType.OriginalText = originalText; SC_R2 <Code> sc = new SC_R2Impl <Code>(codedType); sc.NullFlavor = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION; string result = new ScR2PropertyFormatter().Format(GetContext("name", "SC"), sc); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.IsTrue(this.result.GetHl7Errors()[0].GetMessage().Contains("originalText")); Assert.AreEqual("<name nullFlavor=\"NI\"/>", StringUtils.Trim(result), "result"); }