コード例 #1
0
        public void FindLargestTest()
        {
            var collective = new BlobCollective(1.0, 1.0, 4);

            collective.Split();
            collective.Split();

            var motherBlob = collective.FindLargest(null);

            Assert.AreEqual(0.300, motherBlob.Radius, 0.01);
        }
コード例 #2
0
        public void FindClosestTest()
        {
            var environment = new Environment(0.2, 0.2, 2.6, 1.6);

            var collective = new BlobCollective(1.0, 1.0, 4);

            collective.Split();
            collective.Split();

            collective.Move(1.0);
            collective.Sc(environment);

            var largest   = collective.FindLargest(null);
            var smallest1 = collective.FindSmallest(null);
            var smallest2 = collective.FindSmallest(smallest1);

            var closest = collective.FindClosest(largest);

            Assert.AreSame(smallest2, closest);
        }
コード例 #3
0
        public void FindSmallestTest()
        {
            var collective = new BlobCollective(1.0, 1.0, 4);

            collective.Split();
            collective.Split();

            var largest = collective.FindLargest(null);

            // Find one of the two smallest blobs.
            var smallest1 = collective.FindSmallest(null);

            Assert.AreNotSame(largest, smallest1);
            Assert.AreEqual(0.225, smallest1.Radius, 0.01);

            // Find the other smallest blob.
            var smallest2 = collective.FindSmallest(smallest1);

            Assert.AreNotSame(largest, smallest2);
            Assert.AreNotSame(smallest1, smallest2);
            Assert.AreEqual(0.225, smallest2.Radius, 0.01);
        }
コード例 #4
0
        public void SplitTest()
        {
            var canvas = new Canvas {
                Width = 200, Height = 200
            };

            var collective = new BlobCollective(1.0, 1.0, 4);

            collective.Split();
            Assert.AreEqual(2, collective.NumActive);
            collective.Draw(canvas, 100.0);

            var wpf = new ContentControl {
                Content = canvas
            };

            WpfApprovals.Verify(wpf);
        }