示例#1
0
        public void MultiObjectTestThree()
        {
            var closeIntersector = A.Fake<IEdgeIntersector>();
            var farIntersector = A.Fake<IEdgeIntersector>();

            var closeTrans = new Transform(Vector3.I, Matrix3.Identity);
            var farTrans = new Transform(5 * Vector3.I, Matrix3.Identity);

            var closeObj = new TransformedObj<IEdgeIntersector>(closeTrans, closeIntersector);
            var farObj = new TransformedObj<IEdgeIntersector>(farTrans, farIntersector);

            A.CallTo(() => closeIntersector.FindIntersections(default(Edge)))
                .WithAnyArguments()
                .Returns(new Intersection[] { });
            A.CallTo(() => farIntersector.FindIntersections(default(Edge)))
                .WithAnyArguments()
                .Returns(new Intersection[] { });

            Assert.That(new Ray().Cast(new[] { farObj, closeObj }, Vector3.Zero, Vector3.I, 100), Is.EqualTo(Optional<Hit>.Nothing));
        }
示例#2
0
        public void MultiObjectTestTwo()
        {
            var closeIntersector = A.Fake<IEdgeIntersector>();
            var farIntersector = A.Fake<IEdgeIntersector>();

            var closeTrans = new Transform(Vector3.I, Matrix3.Identity);
            var farTrans = new Transform(5 * Vector3.I, Matrix3.Identity);

            var closeObj = new TransformedObj<IEdgeIntersector>(closeTrans, closeIntersector);
            var farObj = new TransformedObj<IEdgeIntersector>(farTrans, farIntersector);

            A.CallTo(() => closeIntersector.FindIntersections(default(Edge)))
                .WithAnyArguments()
                .Returns(new Intersection[] { });
            A.CallTo(() => farIntersector.FindIntersections(default(Edge)))
                .WithAnyArguments()
                .Returns(new[] { new Intersection() });

            Hit? hit = new Ray().Cast(new[] { farObj, closeObj }, Vector3.Zero, Vector3.I, 100).Match<Hit?>(h => h, () => null);
            Assert.NotNull(hit);
            Assert.That(hit.Value.HitObject, Is.EqualTo(farObj));
        }