Exemple #1
0
        public void SingleNodeEnumerableForEachTwoTimes()
        {
            // to test the enumeration without the usage of reset()
            // (enumerable should yield a new enumerator every time it's called)
            TestNode node = new TestNode();

            var singleNodeEnumerable = VisitorHelpers.SingleRootEnumerable(node);

            int i = 0;

            foreach (var curNode in singleNodeEnumerable)
            {
                Assert.Equal(node, curNode);
                i++;
            }

            Assert.Equal(1, i);

            i = 0;
            foreach (var curNode in singleNodeEnumerable)
            {
                Assert.Equal(node, curNode);
                i++;
            }

            Assert.Equal(1, i);
        }
Exemple #2
0
        public void SingleNodeEnumeratorThrowsOnReset()
        {
            TestNode node = new TestNode();

            var singleNodeEnumerator = VisitorHelpers.SingleRootEnumerator(node);

            // See https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator.reset?view=netcore-3.1:
            // "The Reset method is provided for COM interoperability. It does not necessarily need to be implemented;
            // instead, the implementer can simply throw a NotSupportedException."
            Assert.Throws <NotSupportedException>(() => singleNodeEnumerator.Reset());
        }
Exemple #3
0
        public void SingleNodeEnumerableForEach()
        {
            TestNode node = new TestNode();

            var singleNodeEnumerable = VisitorHelpers.SingleRootEnumerable(node);

            int i = 0;

            foreach (var curNode in singleNodeEnumerable)
            {
                Assert.Equal(node, curNode);
                i++;
            }

            Assert.Equal(1, i);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OBBCalculator"/> class.
 /// </summary>
 /// <param name="snc">A single scene node to calculate an axis-aligned bounding box for.</param>
 public OBBCalculator(SceneNode snc)
 {
     _sncList = VisitorHelpers.SingleRootEnumerable(snc);
 }