public void Group_IterateProperties() { BasicGroup targetGroup = new BasicGroup(TestConstants.anID, TestConstants.aName); BasicProperty propertyAA = new BasicProperty("AA", "AA"); BasicProperty propertyBB = new BasicProperty("BB", "BB"); BasicProperty propertyCC = new BasicProperty("CC", "CC"); List <string> expectedIDs = new List <string>() { "CC", "BB", "AA" }; targetGroup.AddProperty(propertyCC); targetGroup.AddProperty(propertyBB); targetGroup.AddProperty(propertyAA); List <string> actualIds = new List <string>(); foreach (IProperty property in targetGroup.Properties) { actualIds.Add(property.Definition.ID); } Assert.AreEqual(expectedIDs.Count, actualIds.Count); for (int i = 0; i < expectedIDs.Count; i++) { Assert.AreEqual(expectedIDs[i], actualIds[i]); } }
public void Group_AddProperty() { BasicGroup targetGroup = new BasicGroup(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); targetGroup.AddProperty(aProperty); TestUtilities.checkForSingleItem(targetGroup.Properties, aProperty, "Properties"); }
public void Group_RemoveProperty_ByID() { BasicGroup targetGroup = new BasicGroup(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); targetGroup.AddProperty(aProperty); targetGroup.RemoveProperty(TestConstants.anID); TestUtilities.checkEmpty(targetGroup.Properties, "Properties"); }
public void Group_AddProperty_Duplicate() { BasicGroup targetGroup = new BasicGroup(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); ArgumentException expectedException = null; targetGroup.AddProperty(aProperty); try { targetGroup.AddProperty(aProperty); } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException); TestUtilities.checkForSingleItem(targetGroup.Properties, aProperty, "Properties"); }
public void Group_AddProperty_Null() { BasicGroup targetGroup = new BasicGroup(TestConstants.anID, TestConstants.aName); ArgumentNullException expectedException = null; try { targetGroup.AddProperty(null); } catch (ArgumentNullException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propProperty, TestConstants.paramProperty); TestUtilities.checkEmpty(targetGroup.Properties, "Properties"); }