コード例 #1
0
        public void FullConstructor(string name, int salary, FatCat parent)
        {
            FatCat fatCat = new FatCat(name, salary, parent);

            Assert.Equal(name, fatCat.GetName());
            Assert.Equal(salary, fatCat.GetSalary());
            Assert.Equal(parent, fatCat.GetParent());
            Assert.True(fatCat.HasParent(), "HasParent() did not return true when constructed with an owner");
        }
コード例 #2
0
        public void NoOwnerConstructor(string name, int salary)
        {
            FatCat fatCat = new FatCat(name, salary);

            Assert.Equal(name, fatCat.GetName());
            Assert.Equal(salary, fatCat.GetSalary());
            Assert.Null(fatCat.GetParent());
            Assert.False(fatCat.HasParent(), "HasParent() did not return false when constructed without an owner");
        }
コード例 #3
0
        public void GetChildrenFatCatWithParent(MegaCorp megaCorp, FatCat fatCat)
        {
            megaCorp.Add(fatCat);
            ISet <ICapitalist> children = megaCorp.GetChildren(fatCat);

            Assert.Empty(children);
            children = megaCorp.GetChildren(fatCat.GetParent());
            Assert.True(children.Contains(fatCat), "#getChildren() returned a set that does not contain the previously-added FatCat when called with its parent");
        }
コード例 #4
0
        public void GetParentChainMatchesInternalStructure(MegaCorp megaCorp, ICapitalist capitalist)
        {
            megaCorp.Add(capitalist);
            FatCat        parent   = capitalist.GetParent();
            ISet <FatCat> expected = new HashSet <FatCat>();

            while (parent != null)
            {
                expected.Add(parent);
                parent = parent.GetParent();
            }
            Assert.True(expected.SetEquals(megaCorp.GetParentChain(capitalist)),
                        "#GetParentChain() returned a list that did not match the calculated structure of the arbitrary Capitalist that was just added to the MegaCorp");
        }
コード例 #5
0
        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");
        }