public virtual void ShouldBeAbleToRemoveMultipleElementsFromSet() { SET <ST, string> testSet = new SETImpl <ST, string>(typeof(STImpl)); ICollection <string> rawSet = testSet.RawSet(); rawSet.Add("newString1"); rawSet.Add("newString2"); rawSet.Add("newString3"); rawSet.Add("newString4"); rawSet.Add("newString5"); rawSet.Add("newString6"); Assert.IsTrue(testSet.RawSet().Contains("newString2")); bool result = rawSet.Remove("newString2"); Assert.AreEqual(5, testSet.Value.Count); Assert.IsTrue(result); Assert.IsFalse(testSet.RawSet().Contains("newString2")); Assert.IsTrue(testSet.RawSet().Contains("newString6")); bool booleanResult = rawSet.Remove("newString6"); Assert.AreEqual(4, testSet.Value.Count); Assert.IsTrue(booleanResult); Assert.IsFalse(testSet.RawSet().Contains("newString6")); booleanResult = rawSet.Remove("newString123"); Assert.IsFalse(booleanResult); Assert.AreEqual(4, testSet.Value.Count); Assert.IsTrue(testSet.RawSet().Contains("newString1")); Assert.IsTrue(testSet.RawSet().Contains("newString4")); rawSet.Clear(); Assert.IsTrue(testSet.Value.IsEmpty()); Assert.IsTrue(testSet.RawSet().IsEmpty()); }
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); }
/// <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); }
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); } }
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]); }
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); }