public void TestHasPrecedersMethod()
        {
            var solarSystem = new SolarSystem();

            Assert.IsFalse(solarSystem.HasPreceders());

            var milkyWay = new MilkyWay();

            solarSystem.Follows(milkyWay);

            Assert.IsTrue(solarSystem.HasPreceders());
        }
        public void TestHasFollowersMethod()
        {
            var milkyWay = new MilkyWay();

            Assert.IsFalse(milkyWay.HasFollowers());

            var solarSystem = new SolarSystem();

            milkyWay.Precedes(solarSystem);

            Assert.IsTrue(milkyWay.HasFollowers());
        }
예제 #3
0
        public void TestExists()
        {
            // setup
            var coll     = new NodeCollection();
            var milkyWay = new MilkyWay();

            // assert node does not exist
            Assert.IsFalse(coll.Exists(milkyWay));

            // assert node exists
            coll.Add(milkyWay);
            Assert.IsTrue(coll.Exists(milkyWay));
        }
        public void TestPrecederOfFollower()
        {
            // setup
            var milkyWay    = new MilkyWay();
            var solarSystem = new SolarSystem();

            milkyWay.Precedes(solarSystem);
            var solarSystemPreceders   = solarSystem.Preceders;
            var solarSystemHasPreceder = solarSystemPreceders.TryGetValue(typeof(MilkyWay), out var solarSystemPreceder);

            // assertions
            Assert.IsNotNull(solarSystemPreceders);
            Assert.IsTrue(solarSystemHasPreceder);
            Assert.AreSame(solarSystemPreceder, milkyWay);
        }
        public void TestFollowerOfPreceder()
        {
            // setup
            var milkyWay    = new MilkyWay();
            var solarSystem = new SolarSystem();

            milkyWay.Precedes(solarSystem);
            var milkyWayFollowers   = milkyWay.Followers;
            var milkyWayHasFollower = milkyWayFollowers.TryGetValue(typeof(SolarSystem), out var milkyWayFollower);

            // assertions
            Assert.IsTrue(milkyWayHasFollower);
            Assert.IsNotNull(milkyWayFollowers);
            Assert.AreSame(milkyWayFollower, solarSystem);
        }
        public void TestExceptionThrownWhenInitializingTwoNodesOfSameType()
        {
            var dummy1 = new MilkyWay();

            try
            {
                var dummy2 = new MilkyWay();
            }
            catch (ArgumentException)
            {
                Assert.Pass();
            }

            Assert.Fail("Expected ArgumentException (initializing the same node types should not be allowed.");
        }
        public void TestExceptionThrownWhenCallingRedundantFollowAfterPrecede()
        {
            var milkyWay    = new MilkyWay();
            var solarSystem = new SolarSystem();

            milkyWay.Precedes(solarSystem);

            try
            {
                solarSystem.Follows(milkyWay);
            }
            catch (ArgumentException)
            {
                Assert.Pass();
            }

            Assert.Fail("Expected ArgumentException (attempted to assign node relationship twice " +
                        "-- redundant call to a.Follows(b) when already called b.Precedes(a)).");
        }
예제 #8
0
        public void TestExceptionThrownWhenSameNodeAddedTwice()
        {
            var milkyWay = new MilkyWay();

            Assert.AreEqual(this.nodeCollection.Count(), 0);

            this.nodeCollection.Add(milkyWay);
            Assert.AreEqual(this.nodeCollection.Count(), 1);

            try
            {
                this.nodeCollection.Add(milkyWay);
            }
            catch (ArgumentException)
            {
                Assert.Pass();
            }

            Assert.Fail("Expected ArgumentException (attempted to add same node twice).");
        }
예제 #9
0
        public void TestCount()
        {
            // test 0 nodes added
            Assert.AreEqual(this.nodeCollection.Count(), 0);

            // test 1 nodes added
            var lmc = new LMC();

            this.nodeCollection.Add(lmc);
            Assert.AreEqual(this.nodeCollection.Count(), 1);

            // test 2 nodes added
            var milkyWay = new MilkyWay();

            this.nodeCollection.Add(milkyWay);
            Assert.AreEqual(this.nodeCollection.Count(), 2);

            // adding a follower should not increase collection count
            var solarSystem = new SolarSystem();

            milkyWay.Precedes(solarSystem);
            Assert.AreEqual(this.nodeCollection.Count(), 2);
        }