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))); }
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)); }
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))); }
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))); }
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); }
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>()); }
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)); }