예제 #1
0
        public void Does_ContainsPoint_Handles_Degenerate_Case()
        {
            CC3Viewport degenerateViewport = new CC3Viewport(1, 2, 0, 0);

            Assert.IsTrue(degenerateViewport.ContainsPoint(new CCPoint(1,2)));
            Assert.IsFalse(degenerateViewport.ContainsPoint(new CCPoint(1,3)));
        }
예제 #2
0
        public void Is_ContainsPoint_Robust()
        {
            CCRect vpRect = new CCRect(5.0f, -5.0f, 15.0f, 20.0f);
            CCSize vpSize = vpRect.Size;
            CC3Viewport vp = new CC3Viewport(vpRect);

            // General sanity test
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin + new CCPoint(vpSize.Width / 2.0f, vpSize.Height / 2.0f)));

            // Checking corners of viewport
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin));
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin + new CCPoint(vpSize.Width, 0.0f)));
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin + new CCPoint(0.0f, vpSize.Height)));
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin + new CCPoint(vpSize.Width, vpSize.Height)));

            // Test sensitivity to decimal changes in coordinates
            // Floats are cast as ints in viewport fields
            Assert.IsFalse(vp.ContainsPoint(vpRect.Origin + new CCPoint(-0.1f, 0.0f)));
            Assert.IsTrue(vp.ContainsPoint(vpRect.Origin + new CCPoint(0.1f, 0.0f)));
        }