public void GetParentsDefensiveCopy(MegaCorp megaCorp, FatCat fatCat)
        {
            ISet <FatCat> parents = megaCorp.GetParents();

            parents.Add(fatCat);
            Assert.False(megaCorp.Has(fatCat), "#GetParents() returned a live set of parents that allowed external changes to the MegaCorp");
            parents = megaCorp.GetParents();
            Assert.False(parents.Contains(fatCat), "#GetParents() returned a live set of parents that allowed external changes to the MegaCorp");
        }
        public void GetParentsEmpty(MegaCorp megaCorp)
        {
            ISet <FatCat> parents = megaCorp.GetParents();

            Assert.NotNull(parents);
            Assert.Empty(parents);
        }
        public void GetParentsFatCat(MegaCorp megaCorp, FatCat fatCat)
        {
            megaCorp.Add(fatCat);
            ISet <FatCat> parents = megaCorp.GetParents();

            Assert.NotEmpty(parents);
            Assert.Equal(1, parents.Count);
        }
        public void GetParentsWageSlaveWithParent(MegaCorp megaCorp, WageSlave wageSlave)
        {
            megaCorp.Add(wageSlave);
            FatCat        parent  = wageSlave.GetParent();
            ISet <FatCat> parents = megaCorp.GetParents();

            Assert.NotEmpty(parents);
            Assert.Equal(1, parents.Count);
            Assert.True(parents.Contains(parent), "#getParents() returned a set that did not contain the parent of the WageSlave added to the MegaCorp");
        }
        public void GetParentsMultipleArbitraryCapitalists(MegaCorp megaCorp, ISet <ICapitalist> capitalists)
        {
            ISet <FatCat> expected = new HashSet <FatCat>();

            foreach (ICapitalist capitalist in capitalists)
            {
                megaCorp.Add(capitalist);
                FatCat parent = capitalist.GetType() == typeof(FatCat) ? (FatCat)capitalist : capitalist.GetParent();
                while (parent != null)
                {
                    expected.Add(parent);
                    parent = parent.GetParent();
                }
            }
            ISet <FatCat> parents = megaCorp.GetParents();

            Assert.True(expected.SetEquals(parents), "#GetParents() returned a set that did not equal the set of all parents of the added Capitalists");
        }
        public void GetHierarchyConsistencyWithOneLevel(MegaCorp megaCorp)
        {
            IDictionary <FatCat, ISet <ICapitalist> > hierarchy = megaCorp.GetHierarchy();
            ISet <FatCat> expectedParents = megaCorp.GetParents();

            Assert.True(expectedParents.SetEquals(hierarchy.Keys),
                        "#GetHierarchy() returned a map with a key set that did not match the MegaCorp's parents");

            ISet <ICapitalist> actualElements = new HashSet <ICapitalist>();

            foreach (FatCat parent in expectedParents)
            {
                actualElements.Add(parent);
                ISet <ICapitalist> expectedChildren = megaCorp.GetChildren(parent);
                foreach (ICapitalist capitalist in expectedChildren)
                {
                    actualElements.Add(capitalist);
                }
                Assert.True(expectedChildren.SetEquals(hierarchy[parent]),
                            "#GetHierarchy() returned a map in which a key's associated set of values did not match the MegaCorp's children for that key");
            }
            Assert.True(megaCorp.GetElements().SetEquals(actualElements),
                        "#GetHierarchy() returned a map in which a key's associated set of values did not match the MegaCorp's children for that key");
        }