/// <summary> /// Test method for <see cref="MaintainableUtil{T}.FilterCollection" /> /// </summary> public void TestFilterCollection() { var dataflows = new List<IDataflowObject>(); for (int i = 0; i < 5; i++) { var moq = new Mock<IDataflowObject>(); moq.Setup(o => o.AgencyId).Returns((i % 2) == 0 ? "ESTAT" : "TEST"); moq.Setup(o => o.Id).Returns("ID" + i.ToString(CultureInfo.InvariantCulture)); moq.Setup(o => o.Version).Returns("1." + i.ToString(CultureInfo.InvariantCulture)); dataflows.Add(moq.Object); } var dataflowUtil = new MaintainableUtil<IDataflowObject>(); CollectionAssert.AreEquivalent(dataflows, dataflowUtil.FilterCollection(dataflows, null)); CollectionAssert.AreEquivalent(dataflows, dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl())); CollectionAssert.IsSubsetOf(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl("ESTAT", null, null)), dataflows); CollectionAssert.AreNotEquivalent(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl("ESTAT", null, null)), dataflows); CollectionAssert.IsSubsetOf(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl("TEST", null, null)), dataflows); CollectionAssert.AreNotEquivalent(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl("TEST", null, null)), dataflows); CollectionAssert.IsSubsetOf(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, "ID1", null)), dataflows); CollectionAssert.AreNotEquivalent(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, "ID1", null)), dataflows); CollectionAssert.IsSubsetOf(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, "ID1", "1.1")), dataflows); CollectionAssert.AreNotEquivalent(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, "ID1", "1.1")), dataflows); CollectionAssert.IsSubsetOf(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, null, "1.1")), dataflows); CollectionAssert.AreNotEquivalent(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, null, "1.1")), dataflows); CollectionAssert.IsEmpty(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl("NOTHING", null, null))); CollectionAssert.IsEmpty(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, "NO", null))); CollectionAssert.IsEmpty(dataflowUtil.FilterCollection(dataflows, new MaintainableRefObjectImpl(null, null, "5.0"))); }
public virtual ISet<IRegistrationObject> GetRegistrations(IMaintainableRefObject xref) { MaintainableUtil<IRegistrationObject> filter = new MaintainableUtil<IRegistrationObject>(); return filter.FilterCollection(registrations, xref); }