public void TestResolveContactsNotAddMoreContact()
        {
            Settings.ContactIteration = 1;
            Settings.MaxContacts      = 0;

            var pA = new Particle {
                Mass = 1, Position = new Vector2D(0, 0)
            };
            var pB = new Particle {
                Mass = 1, Position = new Vector2D(2, 0)
            };

            pA.BindShape(new Circle(5));
            pB.BindShape(new Circle(5));

            var contactRegistry = new ContactRegistry(new HashSet <PhysicsObject>(), new HashSet <Edge>());

            contactRegistry.Add(new ParticleRope(2, 0, pA, pB));
            contactRegistry.OnContactEvent += (s, a) =>
            {
                Assert.AreEqual(contactRegistry, s);
                Assert.AreEqual(0, a.ContactList.Count);
            };
            contactRegistry.ResolveContacts(1 / 60.0);

            Settings.MaxContacts = 500;
        }
        public void TestResolveContactsStopIteration()
        {
            Settings.ContactIteration = 2;

            var pA = new Particle {
                Mass = 1, Position = new Vector2D(0, 0)
            };
            var pB = new Particle {
                Mass = 1, Position = new Vector2D(2, 0)
            };

            pA.BindShape(new Circle(5));
            pB.BindShape(new Circle(5));
            var objects = new HashSet <PhysicsObject> {
                pA, pB
            };


            var contactRegistry = new ContactRegistry(objects, new HashSet <Edge>());

            contactRegistry.OnContactEvent += (s, a) =>
            {
                _isRan = true;
                Assert.AreEqual(contactRegistry, s);
                Assert.AreEqual(1, a.ContactList.Count);
            };

            contactRegistry.ResolveContacts(1 / 60.0);
            Assert.IsTrue(_isRan);
        }
        public void TestResolveContacts()
        {
            Settings.ContactIteration = 1;

            var pA = new Particle {
                Mass = 1, Position = new Vector2D(0, 0)
            };
            var pB = new Particle {
                Mass = 1, Position = new Vector2D(2, 0)
            };

            pA.BindShape(new Circle(5));
            pB.BindShape(new Circle(5));
            var objects = new HashSet <PhysicsObject> {
                pA, pB
            };

            var edge  = new Edge(0, 4, 4, 4);
            var edges = new HashSet <Edge> {
                edge
            };

            var contactRegistry = new ContactRegistry(objects, edges);

            contactRegistry.OnContactEvent += (s, a) =>
            {
                Assert.AreEqual(contactRegistry, s);
                Assert.AreEqual(3, a.ContactList.Count);
            };

            contactRegistry.ResolveContacts(1 / 60.0);
        }