Exemplo n.º 1
0
        public void TestAddAnnotation()
        {
            FhirBoolean data = new FhirBoolean();

            Assert.IsNull(data.Annotation(typeof(AnnotationData)));
            data.AddAnnotation(new AnnotationData {
                Data = "hi!"
            });
            Assert.IsNotNull(data.Annotation(typeof(AnnotationData)));
            Assert.AreEqual("hi!", data.Annotation <AnnotationData>().Data);
            Assert.AreEqual(1, data.Annotations(typeof(AnnotationData)).Count());

            data.AddAnnotation(new AnnotationData {
                Data = "hi2!"
            });

            // Does not change original outcome (still the first)
            Assert.IsNotNull(data.Annotation(typeof(AnnotationData)));
            Assert.AreEqual("hi!", data.Annotation <AnnotationData>().Data);

            Assert.AreEqual(2, data.Annotations(typeof(AnnotationData)).Count());
            Assert.AreEqual("hi2!", data.Annotations <AnnotationData>().Skip(1).First().Data);

            data.AddAnnotation("Bare string");

            Assert.AreEqual(2, data.Annotations(typeof(AnnotationData)).Count());
            Assert.AreEqual("hi!", data.Annotation <AnnotationData>().Data);

            data.RemoveAnnotations <AnnotationData>();
            Assert.AreEqual(0, data.Annotations(typeof(AnnotationData)).Count());

            Assert.AreEqual("Bare string", data.Annotation <string>());
        }
Exemplo n.º 2
0
        public void TestAnnotationsAreCloneable()
        {
            FhirBoolean data = new FhirBoolean(true);

            data.AddAnnotation(new AnnotationData {
                Data = "Hi!"
            });

            var copied = (FhirBoolean)data.DeepCopy();

            Assert.AreEqual("Hi!", copied.Annotation <AnnotationData>().Data);
        }