コード例 #1
0
        public void WithPrimary(int x, int y)
        {
            var selector = new PolygonalRegionSelector();

            var selector2 = (PolygonalRegionSelector)selector.WithPrimary(new Vector(x, y));

            Assert.That(selector2.PrimaryPosition, Is.EqualTo(new Vector(x, y)));
        }
コード例 #2
0
        public void Positions()
        {
            var selector = new PolygonalRegionSelector(new[] { Vector.Zero, Vector.One, Vector.One });

            Assert.That(selector.Positions, Has.Count.EqualTo(3));
            Assert.That(selector.Positions[0], Is.EqualTo(Vector.Zero));
            Assert.That(selector.Positions[1], Is.EqualTo(Vector.One));
            Assert.That(selector.Positions[2], Is.EqualTo(Vector.One));
        }
コード例 #3
0
        public void WithPrimary_PreviousSelected(int x, int y)
        {
            RegionSelector selector = new PolygonalRegionSelector();

            selector = selector.WithPrimary(Vector.Zero);
            selector = selector.WithSecondary(Vector.One);

            var selector2 = (PolygonalRegionSelector)selector.WithPrimary(new Vector(x, y));

            Assert.That(selector2.PrimaryPosition, Is.EqualTo(new Vector(x, y)));
        }
コード例 #4
0
        public void WithSecondary(int x, int y)
        {
            RegionSelector selector = new PolygonalRegionSelector();

            selector = selector.WithPrimary(Vector.Zero);

            var selector2 = (PolygonalRegionSelector)selector.WithSecondary(new Vector(x, y));

            Assert.That(selector2.Positions, Has.Count.EqualTo(2));
            Assert.That(selector2.Positions[1], Is.EqualTo(new Vector(x, y)));
        }
コード例 #5
0
        public void Clear()
        {
            RegionSelector selector = new PolygonalRegionSelector();

            selector = selector.WithPrimary(Vector.Zero);
            selector = selector.WithSecondary(Vector.One);
            selector = selector.WithSecondary(Vector.One);

            var selector2 = (PolygonalRegionSelector)selector.Clear();

            Assert.That(selector2.Positions, Is.Empty);
        }
コード例 #6
0
        public void GetRegion_LessThanThreePositions_NullRegion(int count)
        {
            RegionSelector selector = new PolygonalRegionSelector();

            if (count-- > 0)
            {
                selector = selector.WithPrimary(Vector.Zero);
            }
            while (count-- > 0)
            {
                selector = selector.WithSecondary(Vector.Zero);
            }

            Assert.That(selector.GetRegion(), Is.InstanceOf <EmptyRegion>());
        }
コード例 #7
0
        public void GetRegion()
        {
            RegionSelector selector = new PolygonalRegionSelector();

            selector = selector.WithPrimary(Vector.Zero);
            selector = selector.WithSecondary(Vector.One);
            selector = selector.WithSecondary(Vector.One);

            var region = (PolygonalRegion)selector.GetRegion();

            Assert.That(region.Vertices, Has.Count.EqualTo(3));
            Assert.That(region.Vertices[0], Is.EqualTo(Vector.Zero));
            Assert.That(region.Vertices[1], Is.EqualTo(Vector.One));
            Assert.That(region.Vertices[2], Is.EqualTo(Vector.One));
        }