style(shapes): remove redundant usings and document PipeSizes bound
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenNest.Shapes
|
namespace OpenNest.Shapes
|
||||||
{
|
{
|
||||||
@@ -7,7 +6,7 @@ namespace OpenNest.Shapes
|
|||||||
{
|
{
|
||||||
public readonly record struct Entry(string Label, double OuterDiameter);
|
public readonly record struct Entry(string Label, double OuterDiameter);
|
||||||
|
|
||||||
public static IReadOnlyList<Entry> All { get; } = new List<Entry>
|
public static IReadOnlyList<Entry> All { get; } = new[]
|
||||||
{
|
{
|
||||||
new Entry("1/8", 0.405),
|
new Entry("1/8", 0.405),
|
||||||
new Entry("1/4", 0.540),
|
new Entry("1/4", 0.540),
|
||||||
@@ -61,9 +60,19 @@ namespace OpenNest.Shapes
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all pipe sizes whose outer diameter is less than or equal to <paramref name="maxOD"/>.
|
||||||
|
/// The bound is inclusive.
|
||||||
|
/// </summary>
|
||||||
public static IEnumerable<Entry> GetFittingSizes(double maxOD)
|
public static IEnumerable<Entry> GetFittingSizes(double maxOD)
|
||||||
{
|
{
|
||||||
return All.Where(e => e.OuterDiameter <= maxOD);
|
foreach (var entry in All)
|
||||||
|
{
|
||||||
|
if (entry.OuterDiameter <= maxOD)
|
||||||
|
{
|
||||||
|
yield return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,16 @@ public class PipeSizesTests
|
|||||||
Assert.DoesNotContain(results, e => e.Label == "4");
|
Assert.DoesNotContain(results, e => e.Label == "4");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetFittingSizes_ExactBoundary_IsInclusive()
|
||||||
|
{
|
||||||
|
// NPS 3 has OD 3.500; passing maxOD = 3.500 should include it.
|
||||||
|
var results = PipeSizes.GetFittingSizes(3.500).ToList();
|
||||||
|
|
||||||
|
Assert.Contains(results, e => e.Label == "3");
|
||||||
|
Assert.DoesNotContain(results, e => e.Label == "3 1/2");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetFittingSizes_MaxSmallerThanSmallest_ReturnsEmpty()
|
public void GetFittingSizes_MaxSmallerThanSmallest_ReturnsEmpty()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user