Skip to content

Commit

Permalink
Merge pull request #43 from MagmaWorks/task/width-x-height
Browse files Browse the repository at this point in the history
Size (WxH)
  • Loading branch information
kpne authored Nov 14, 2024
2 parents 2dbb89a + fd771c6 commit 0b6825b
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/EllipseHollowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CreateProfileTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IEllipseHollow prfl = new EllipseHollow(h, w, thk);
IEllipseHollow prfl = new EllipseHollow(w, h, thk);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -34,7 +34,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IEllipseHollow prfl = new EllipseHollow(h, w, thk);
IEllipseHollow prfl = new EllipseHollow(w, h, thk);
string json = prfl.ToJson();
IEllipseHollow prflDeserialized = json.FromJson<IEllipseHollow>();

Expand All @@ -53,7 +53,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IEllipseHollow prfl = new EllipseHollow(h, w, thk);
IEllipseHollow prfl = new EllipseHollow(w, h, thk);
string json = prfl.ToJson();
IEllipseHollow prflDeserialized = json.FromJson<EllipseHollow>();

Expand All @@ -72,7 +72,7 @@ public void GetPerimeterTest()
var thk = new Length(14.3, LengthUnit.Millimeter);

// Act
IEllipseHollow prfl = new EllipseHollow(h, w, thk);
IEllipseHollow prfl = new EllipseHollow(w, h, thk);
IPerimeter perimeter = new Perimeter(prfl, 57);

// Assert
Expand Down
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/EllipseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void CreateProfileTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IEllipse prfl = new Ellipse(h, w);
IEllipse prfl = new Ellipse(w, h);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -31,7 +31,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IEllipse prfl = new Ellipse(h, w);
IEllipse prfl = new Ellipse(w, h);
string json = prfl.ToJson();
IEllipse prflDeserialized = json.FromJson<IEllipse>();

Expand All @@ -48,7 +48,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IEllipse prfl = new Ellipse(h, w);
IEllipse prfl = new Ellipse(w, h);
string json = prfl.ToJson();
IEllipse prflDeserialized = json.FromJson<Ellipse>();

Expand All @@ -65,7 +65,7 @@ public void GetPerimeterTest()
var w = new Length(18, LengthUnit.Centimeter);

// Act
IEllipse prfl = new Ellipse(h, w);
IEllipse prfl = new Ellipse(w, h);
IPerimeter perimeter = new Perimeter(prfl, 57);

// Assert
Expand Down
128 changes: 128 additions & 0 deletions Profiles/ProfileTests/IParallelFlangeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using MagmaWorks.Taxonomy.Profiles;
using OasysUnits;
using OasysUnits.Units;
using ProfileTests.Utility;

namespace ProfileTests
Expand Down Expand Up @@ -120,5 +122,131 @@ public void GetPerimeterTest()
TestUtility.TestListsOfDoublesAreEqual(expectedU, u);
TestUtility.TestListsOfDoublesAreEqual(expectedV, v);
}

[Fact]
public void GetPerimeterMockTest()
{
// Assemble
IIParallelFlange prfl = new MockHEB500();

// Act
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Assert.Equal(45, perimeter.OuterEdge.Points.Count);
List<double> u = perimeter.OuterEdge.Points.Select(x => x.Y.Millimeters).ToList();
List<double> v = perimeter.OuterEdge.Points.Select(x => x.Z.Millimeters).ToList();

var expectedU = new List<double>()
{
-150,
150,
150,
34.25,
28.982561305564538,
23.917547326142575,
19.249603708470747,
15.158116907963219,
11.800320467831277,
9.305252622195258,
7.76879742911278,
7.25,
7.25,
7.76879742911278,
9.305252622195255,
11.800320467831273,
15.158116907963212,
19.24960370847074,
23.91754732614256,
28.982561305564527,
34.24999999999999,
150,
150,
-150,
-150,
-34.25000000000001,
-28.982561305564538,
-23.917547326142568,
-19.24960370847075,
-15.158116907963223,
-11.800320467831277,
-9.305252622195265,
-7.76879742911278,
-7.25,
-7.25,
-7.76879742911278,
-9.305252622195258,
-11.800320467831277,
-15.158116907963215,
-19.249603708470737,
-23.917547326142575,
-28.982561305564534,
-34.25,
-150,
-150
};

var expectedV = new List<double>() {
250,
250,
222,
222,
221.4812025708872,
219.94474737780473,
217.44967953216872,
214.0918830920368,
210.00039629152926,
205.33245267385743,
200.26743869443547,
195,
-195,
-200.26743869443547,
-205.33245267385743,
-210.00039629152926,
-214.09188309203677,
-217.44967953216872,
-219.94474737780473,
-221.4812025708872,
-222,
-222,
-250,
-250,
-222,
-222,
-221.4812025708872,
-219.94474737780473,
-217.44967953216872,
-214.0918830920368,
-210.00039629152926,
-205.33245267385743,
-200.26743869443547,
-195,
195,
200.26743869443547,
205.33245267385743,
210.00039629152926,
214.0918830920368,
217.44967953216872,
219.94474737780473,
221.4812025708872,
222,
222,
250
};

TestUtility.TestListsOfDoublesAreEqual(expectedU, u);
TestUtility.TestListsOfDoublesAreEqual(expectedV, v);
}
}

public class MockHEB500 : IIParallelFlange
{
public Length FilletRadius => new Length(27, LengthUnit.Millimeter);
public Length Height => new Length(500, LengthUnit.Millimeter);
public Length Width => new Length(300, LengthUnit.Millimeter);
public Length FlangeThickness => new Length(28, LengthUnit.Millimeter);
public Length WebThickness => new Length(14.5, LengthUnit.Millimeter);

public MockHEB500() { }
}
}
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/RectangleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void CreateProfileTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IRectangle prfl = new Rectangle(h, w);
IRectangle prfl = new Rectangle(w, h);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -31,7 +31,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IRectangle prfl = new Rectangle(h, w);
IRectangle prfl = new Rectangle(w, h);
string json = prfl.ToJson();
IRectangle prflDeserialized = json.FromJson<IRectangle>();

Expand All @@ -48,7 +48,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var w = new Length(5.4, LengthUnit.Centimeter);

// Act
IRectangle prfl = new Rectangle(h, w);
IRectangle prfl = new Rectangle(w, h);
string json = prfl.ToJson();
IRectangle prflDeserialized = json.FromJson<Rectangle>();

Expand All @@ -65,7 +65,7 @@ public void GetPerimeterTest()
var w = new Length(50.4, LengthUnit.Centimeter);

// Act
IRectangle prfl = new Rectangle(h, w);
IRectangle prfl = new Rectangle(w, h);
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Expand Down
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/RectangularHollowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CreateProfileTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IRectangularHollow prfl = new RectangularHollow(h, w, thk);
IRectangularHollow prfl = new RectangularHollow(w, h, thk);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -34,7 +34,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IRectangularHollow prfl = new RectangularHollow(h, w, thk);
IRectangularHollow prfl = new RectangularHollow(w, h, thk);
string json = prfl.ToJson();
IRectangularHollow prflDeserialized = json.FromJson<IRectangularHollow>();

Expand All @@ -53,7 +53,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IRectangularHollow prfl = new RectangularHollow(h, w, thk);
IRectangularHollow prfl = new RectangularHollow(w, h, thk);
string json = prfl.ToJson();
IRectangularHollow prflDeserialized = json.FromJson<RectangularHollow>();

Expand All @@ -72,7 +72,7 @@ public void GetPerimeterTest()
var thk = new Length(10.9, LengthUnit.Millimeter);

// Act
IRectangularHollow prfl = new RectangularHollow(h, w, thk);
IRectangularHollow prfl = new RectangularHollow(w, h, thk);
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Expand Down
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/RoundedRectangleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void CreateProfileTest()
var w1 = new Length(4, LengthUnit.Centimeter);

// Act
IRoundedRectangle prfl = new RoundedRectangle(h, w, h1, w1);
IRoundedRectangle prfl = new RoundedRectangle(w, h, w1, h1);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -37,7 +37,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var w1 = new Length(4, LengthUnit.Centimeter);

// Act
IRoundedRectangle prfl = new RoundedRectangle(h, w, h1, w1);
IRoundedRectangle prfl = new RoundedRectangle(w, h, w1, h1);
string json = prfl.ToJson();
IRoundedRectangle prflDeserialized = json.FromJson<IRoundedRectangle>();

Expand All @@ -58,7 +58,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var w1 = new Length(4, LengthUnit.Centimeter);

// Act
IRoundedRectangle prfl = new RoundedRectangle(h, w, h1, w1);
IRoundedRectangle prfl = new RoundedRectangle(w, h, w1, h1);
string json = prfl.ToJson();
IRoundedRectangle prflDeserialized = json.FromJson<RoundedRectangle>();

Expand All @@ -79,7 +79,7 @@ public void GetPerimeterTest()
var w1 = new Length(10, LengthUnit.Centimeter);

// Act
IRoundedRectangle prfl = new RoundedRectangle(h, w, h1, w1);
IRoundedRectangle prfl = new RoundedRectangle(w, h, w1, h1);
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Expand Down
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/RoundedRectangularHollowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CreateProfileTest()
var thk = new Length(3.8, LengthUnit.Millimeter);

// Act
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(h, w, h1, w1, thk);
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(w, h, w1, h1, thk);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -40,7 +40,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var thk = new Length(3.8, LengthUnit.Millimeter);

// Act
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(h, w, h1, w1, thk);
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(w, h, w1, h1, thk);
string json = prfl.ToJson();
IRoundedRectangularHollow prflDeserialized = json.FromJson<IRoundedRectangularHollow>();

Expand All @@ -63,7 +63,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var thk = new Length(3.8, LengthUnit.Millimeter);

// Act
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(h, w, h1, w1, thk);
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(w, h, w1, h1, thk);
string json = prfl.ToJson();
IRoundedRectangularHollow prflDeserialized = json.FromJson<RoundedRectangularHollow>();

Expand All @@ -86,7 +86,7 @@ public void GetPerimeterTest()
var thk = new Length(5.5, LengthUnit.Millimeter);

// Act
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(h, w, h1, w1, thk);
IRoundedRectangularHollow prfl = new RoundedRectangularHollow(w, h, w1, h1, thk);
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Expand Down
8 changes: 4 additions & 4 deletions Profiles/ProfileTests/TrapezoidTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CreateProfileTest()
var wBottom = new Length(0.5, LengthUnit.Meter);

// Act
ITrapezoid prfl = new Trapezoid(h, wTop, wBottom);
ITrapezoid prfl = new Trapezoid(wTop, wBottom, h);

// Assert
TestUtility.TestLengthsAreEqual(h, prfl.Height);
Expand All @@ -34,7 +34,7 @@ public void InterfaceSurvivesRoundtripDeserializationTest()
var wBottom = new Length(0.5, LengthUnit.Meter);

// Act
ITrapezoid prfl = new Trapezoid(h, wTop, wBottom);
ITrapezoid prfl = new Trapezoid(wTop, wBottom, h);
string json = prfl.ToJson();
ITrapezoid prflDeserialized = json.FromJson<ITrapezoid>();

Expand All @@ -53,7 +53,7 @@ public void ConcreteImplementationSurvivesRoundtripDeserializationTest()
var wBottom = new Length(0.5, LengthUnit.Meter);

// Act
ITrapezoid prfl = new Trapezoid(h, wTop, wBottom);
ITrapezoid prfl = new Trapezoid(wTop, wBottom, h);
string json = prfl.ToJson();
ITrapezoid prflDeserialized = json.FromJson<Trapezoid>();

Expand All @@ -72,7 +72,7 @@ public void GetPerimeterTest()
var wBottom = new Length(0.5, LengthUnit.Meter);

// Act
ITrapezoid prfl = new Trapezoid(h, wTop, wBottom);
ITrapezoid prfl = new Trapezoid(wTop, wBottom, h);
IPerimeter perimeter = new Perimeter(prfl);

// Assert
Expand Down
2 changes: 1 addition & 1 deletion Profiles/Profiles/Ellipse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Ellipse : IEllipse
public Length Height { get; set; }
public Length Width { get; set; }

public Ellipse(Length height, Length width)
public Ellipse(Length width, Length height)
{
Height = height;
Width = width;
Expand Down
Loading

0 comments on commit 0b6825b

Please sign in to comment.