Beispiel #1
0
        /// <summary>
        /// Builds an HL7 SET from an existing   Set.
        /// </summary>
        ///
        /// <param name="T"> the HL7 datatype held by the SET</param>
        /// <param name="V"> the underlying   datatype held by the underlying   Set</param>
        /// <param name="rawElementType">the class of the underlying   datatype held by the set</param>
        /// <param name="rawElements">a set of   datatype values</param>
        /// <returns>the constructed SET</returns>
        /* @SuppressWarnings("unchecked")*/
        public static SET <TS, VS> Create <TS, VS>(Type rawElementType, ICollection <VS> rawElements)  where TS : ANY <VS>
        {
            SETImpl <TS, VS> list = new SETImpl <TS, VS>(rawElementType);

            list.RawSet().AddAll(rawElements);
            return(list);
        }
Beispiel #2
0
        public virtual void ShouldBeAbleToCreateSet()
        {
            SET <ST, string> testSet = new SETImpl <ST, string>(typeof(STImpl));

            Assert.AreEqual(StandardDataType.SET, testSet.DataType);
            Assert.IsTrue(testSet.Value.IsEmpty());
            Assert.IsNull(testSet.NullFlavor);
        }
Beispiel #3
0
        public virtual void ShouldBeAbleToAddToSet()
        {
            SET <ST, string>     testSet = new SETImpl <ST, string>(typeof(STImpl));
            ICollection <string> rawSet  = testSet.RawSet <string>();

            rawSet.Add("newString");
            Assert.IsFalse(testSet.Value.IsEmpty());
            Assert.AreEqual(1, testSet.Value.Count);
            Assert.AreEqual(1, testSet.RawSet().Count);

            IEnumerator <ST> enumerator = testSet.Value.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("newString", enumerator.Current.Value);
            Assert.IsNull(enumerator.Current.NullFlavor);
        }
Beispiel #4
0
        public virtual void ShouldBeAbleToIterateRawSet()
        {
            SET <ST, string>     testSet = new SETImpl <ST, string>(typeof(STImpl));
            ICollection <string> rawSet  = testSet.RawSet();

            rawSet.Add("newString0");
            rawSet.Add("newString1");
            rawSet.Add("newString2");
            rawSet.Add("newString3");
            int i = 0;

            for (IEnumerator <string> iterator = rawSet.GetEnumerator(); iterator.MoveNext(); i++)
            {
                string @string = iterator.Current;
                Assert.AreEqual("newString" + i, @string);
            }
        }
Beispiel #5
0
        public virtual void ShouldBeAbleToAddMultipleElementsToSet()
        {
            SET <ST, string>     testSet = new SETImpl <ST, string>(typeof(STImpl));
            ICollection <string> rawSet  = testSet.RawSet();

            rawSet.Add("newString1");
            rawSet.Add("newString2");
            Assert.IsFalse(testSet.Value.IsEmpty());
            Assert.AreEqual(2, testSet.Value.Count);
            Assert.IsTrue(testSet.RawSet().Contains("newString1"));
            Assert.IsTrue(testSet.RawSet().Contains("newString2"));
            rawSet.Add("newString3");
            Assert.AreEqual(3, testSet.Value.Count);
            Assert.IsTrue(testSet.RawSet().Contains("newString3"));
            bool result = rawSet.AddAll(Arrays.AsList("newString4", "newString5"));

            Assert.IsTrue(result);
            Assert.AreEqual(5, testSet.Value.Count);
            Assert.IsTrue(testSet.RawSet().Contains("newString4"));
            Assert.IsTrue(testSet.RawSet().Contains("newString5"));
            Assert.AreEqual(5, testSet.Value.Count);
        }
Beispiel #6
0
        public virtual void ShouldBeAbleToObtainArrayFromSet()
        {
            SET <ST, string>     testSet = new SETImpl <ST, string>(typeof(STImpl));
            ICollection <string> rawSet  = testSet.RawSet();

            rawSet.Add("newString0");
            rawSet.Add("newString1");
            rawSet.Add("newString2");
            rawSet.Add("newString3");
            object[] array = rawSet.ToArray(null);
            Assert.AreEqual(4, array.Length);
            Assert.AreEqual("newString0", array[0]);
            Assert.AreEqual("newString1", array[1]);
            Assert.AreEqual("newString2", array[2]);
            Assert.AreEqual("newString3", array[3]);
            string[] array2 = rawSet.ToArray(new string[0]);
            Assert.AreEqual(4, array.Length);
            Assert.AreEqual("newString0", array2[0]);
            Assert.AreEqual("newString1", array2[1]);
            Assert.AreEqual("newString2", array2[2]);
            Assert.AreEqual("newString3", array2[3]);
        }