Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
add tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
molostovvs authored Dec 16, 2023
1 parent b36eb47 commit dd35cd1
Show file tree
Hide file tree
Showing 37 changed files with 1,431 additions and 646 deletions.
144 changes: 144 additions & 0 deletions Fluent.Structures.Model.UnitTests/BeamTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
namespace Fluent.Structures.Model.UnitTests;

public class BeamTests
{
private TSM.Beam _tekla = null!;

private readonly TSG.Point _startPoint = new(1, 2, 3);
private readonly TSG.Point _endPoint = new(4, 5, 6);
private readonly TSM.Profile _profile = new() { ProfileString = "D567", };
private readonly TSM.Material _material = new() { MaterialString = "C355", };
private const string Class = "654321";
private const string Name = "Beam name";
private readonly TSM.NumberingSeries _partNumber = new("part", 101);
private readonly TSM.NumberingSeries _assemblyNumber = new("assembly", 909);
private const TSM.Part.CastUnitTypeEnum CastUnitType = TSM.Part.CastUnitTypeEnum.CAST_IN_PLACE;
private const string Finish = "Painting";
private readonly TS.Identifier _identifier = new(1234567);
private const int PourPhase = 4567;

private readonly TSM.Offset _startPointOffset = new()
{
Dx = 67,
Dy = 73,
Dz = 81,
};

private readonly TSM.Offset _endPointOffset = new()
{
Dx = 93,
Dy = 97,
Dz = 103,
};

private readonly TSM.DeformingData _deformingData = new()
{
Shortening = 14d,
Cambering = 3.5d,
Angle = 45d,
Angle2 = 90d,
};

private readonly TSM.Position _position = new()
{
Depth = TSM.Position.DepthEnum.MIDDLE,
DepthOffset = 12,
Rotation = TSM.Position.RotationEnum.TOP,
RotationOffset = 23,
Plane = TSM.Position.PlaneEnum.RIGHT,
PlaneOffset = 34,
};

[SetUp]
public void SetupTeklaBeam()
=> _tekla = new TSM.Beam()
{
StartPoint = _startPoint,
EndPoint = _endPoint,
Profile = _profile,
Material = _material,
Class = Class,
Name = Name,
PartNumber = _partNumber,
AssemblyNumber = _assemblyNumber,
Position = _position,
CastUnitType = CastUnitType,
Finish = Finish,
Identifier = _identifier,
DeformingData = _deformingData,
PourPhase = PourPhase,
StartPointOffset = _startPointOffset,
EndPointOffset = _endPointOffset,
};

[Test]
public void Required_fluent_properties_equals_to_tekla_properties()
{
var fluent = GetDefaultFluentBeam().Build();

fluent.StartPoint.Should().BeEquivalentTo(_tekla.StartPoint);
fluent.EndPoint.Should().BeEquivalentTo(_tekla.EndPoint);
fluent.Profile.Should().BeEquivalentTo(_tekla.Profile.ProfileString);
fluent.Material.Should().BeEquivalentTo(_tekla.Material.MaterialString);
}

[Test]
public void All_fluent_properties_equals_to_tekla_properties()
{
var fluent = GetDefaultFluentBeam()
.Class(Class)
.Name(Name)
.PartNumbering(_partNumber.Prefix, _partNumber.StartNumber)
.AssemblyNumbering(_assemblyNumber.Prefix, _assemblyNumber.StartNumber)
.DepthPosition(_position.Depth, _position.DepthOffset)
.PlanePosition(_position.Plane, _position.PlaneOffset)
.RotationPosition(_position.Rotation, _position.RotationOffset)
.CastUnitType(CastUnitType)
.Finish(Finish)
.Identifier(_identifier)
.DeformingData(_deformingData)
.PourPhase(PourPhase)
.StartPointOffset(_startPointOffset)
.EndPointOffset(_endPointOffset)
.Build();

fluent.Class.Should().BeEquivalentTo(_tekla.Class);
fluent.Name.Should().BeEquivalentTo(_tekla.Name);
fluent.PartPrefix.Should().BeEquivalentTo(_tekla.PartNumber.Prefix);
fluent.PartStartNumber.Should().Be(_tekla.PartNumber.StartNumber);
fluent.AssemblyPrefix.Should().BeEquivalentTo(_tekla.AssemblyNumber.Prefix);
fluent.AssemblyStartNumber.Should().Be(_tekla.AssemblyNumber.StartNumber);
fluent.DepthPosition.Should().Be(_tekla.Position.Depth);
fluent.DepthOffset.Should().Be(_tekla.Position.DepthOffset);
fluent.PlanePosition.Should().Be(_tekla.Position.Plane);
fluent.PlaneOffset.Should().Be(_tekla.Position.PlaneOffset);
fluent.RotationPosition.Should().Be(_tekla.Position.Rotation);
fluent.RotationOffset.Should().Be(_tekla.Position.RotationOffset);
fluent.CastUnitType.Should().Be(_tekla.CastUnitType);
fluent.Finish.Should().BeEquivalentTo(_tekla.Finish);
fluent.Identifier.Should().BeEquivalentTo(_tekla.Identifier);
fluent.DeformingData.Should().BeEquivalentTo(_tekla.DeformingData);
fluent.PourPhase.Should().Be(_tekla.PourPhase);
fluent.StartPointOffset.Should().BeEquivalentTo(_tekla.StartPointOffset);
fluent.EndPointOffset.Should().BeEquivalentTo(_tekla.EndPointOffset);
}

[Test]
public void Fluent_default_beam_properties_is_set()
{
var fluent = Beam.BuildBeam.Default().Build();

fluent.StartPoint.Should().NotBeNull();
fluent.EndPoint.Should().NotBeNull();
fluent.Profile.Should().NotBeNullOrEmpty();
fluent.Material.Should().NotBeNullOrEmpty();
fluent.Class.Should().NotBeNullOrEmpty();
}

private ICompletedBeam GetDefaultFluentBeam()
=> Beam.BuildBeam.With()
.StartPoint(_startPoint)
.EndPoint(_endPoint)
.Profile(_profile.ProfileString)
.Material(_material.MaterialString);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>

<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="NUnit" Version="3.13.3"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
<PackageReference Include="NUnit.Analyzers" Version="3.3.0"/>
<PackageReference Include="coverlet.collector" Version="3.1.2"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Fluent.Structures.Model\Fluent.Structures.Model.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions Fluent.Structures.Model.UnitTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Global using directives

global using System.Collections;
global using FluentAssertions;
global using NUnit.Framework;
global using TS = Tekla.Structures;
global using TSG = Tekla.Structures.Geometry3d;
global using TSM = Tekla.Structures.Model;
45 changes: 45 additions & 0 deletions Fluent.Structures.Model.UnitTests/PolygonTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Fluent.Structures.Model.UnitTests;

public class PolygonTests
{
private ArrayList _points = new()
{
new TSG.Point(1, 2, 3), new TSG.Point(4, 5, 6), new TSG.Point(7, 8, 9),
new TSG.Point(10, 11, 12), new TSG.Point(13, 14, 15),
};

private TSM.Polygon _tekla = null!;

[SetUp]
public void SetupTeklaPolygon()
=> _tekla = new TSM.Polygon
{ Points = _points, };

[Test]
public void Fluent_polygon_from_arraylist_equals_tekla_polygon()
{
var fluent = Polygon.BuildPolygon.With().Points(_points).Build();

fluent.Points.Should().BeEquivalentTo(_tekla.Points.Cast<TSG.Point>());
}

[Test]
public void Fluent_polygon_from_array_equals_tekla_polygon()
{
var fluent = Polygon.BuildPolygon.With()
.Points(_points.Cast<TSG.Point>().ToArray())
.Build();

fluent.Points.Should().BeEquivalentTo(_tekla.Points.Cast<TSG.Point>());
}

[Test]
public void Fluent_polygon_from_list_equals_tekla_polygon()
{
var fluent = Polygon.BuildPolygon.With()
.Points(_points.Cast<TSG.Point>().ToList())
.Build();

fluent.Points.Should().BeEquivalentTo(_tekla.Points.Cast<TSG.Point>());
}
}
Loading

0 comments on commit dd35cd1

Please sign in to comment.