Добавил тест для прямоугольника

This commit is contained in:
Evgeny Redikultsev
2022-06-21 22:07:42 +05:00
parent 068b865a89
commit 6d0f2136e3
24 changed files with 389 additions and 11 deletions

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
{
class RCSectionTest
{
}
}

View File

@@ -0,0 +1,55 @@
using LoaderCalculator;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Tests.Infrastructures.Logics;
using NUnit.Framework;
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
using StructureHelperLogics.NdmCalculations.Materials;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System.Collections.Generic;
using System.Threading;
namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
{
public class ReinforcementTest
{
[TestCase(0.3, 0.6, 4e8, 0, 0, 1800000, 0d, 0d, 5e-5d)]
[TestCase(0.3, 0.6, 4e8, 0, 0, -1800000, 0d, 0d, -5e-5d)]
[TestCase(0.3, 0.6, 4e8, 7000000, 0, 0, 0.0065882684745345067d, 0d, 0d)]
[TestCase(0.3, 0.6, 6e8, 10000000, 0, 0, 0.010485801788961743d, 0d, -0.00011114996218404612d)]
public void Run_ShouldPass(double width, double height, double strength, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
ICenter center = new Center() { X = 0, Y = 0 };
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 };
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
primitives.Add(primitive);
var ndmList = Triangulation.GetNdms(primitives, options);
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.01,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
},
NdmCollection = ndmList
};
var calculator = new Calculator();
//Act
calculator.Run(loaderData, new CancellationToken());
var results = calculator.Result;
//Assert
Assert.NotNull(results);
var strainMatrix = results.StrainMatrix;
Assert.NotNull(strainMatrix);
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
}
}
}

View File

@@ -39,6 +39,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="FunctionalTests\Ndms\RCSections\RCSectionTest.cs" />
<Compile Include="FunctionalTests\Ndms\SteelSections\ReinforcementTest.cs" />
<Compile Include="Infrastructures\Logics\ExpectedProcessor.cs" />
<Compile Include="LibrariesTests\Ndms\RCSections\RCSectionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -69,9 +71,7 @@
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="FunctionalTests\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj">
<Project>{330bef5b-15be-4d2c-a750-b1ae50fb2be3}</Project>

View File

@@ -34,7 +34,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
{
//Arrange
IMaterial material = new Material();
ICenter center = new Center() { CenterX = centerX, CenterY = centerY };
ICenter center = new Center() { X = centerX, Y = centerY };
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = angle };
IRectangleTriangulationOptions options = new RectangleTriangulationOptions(center, rectangle, ndmMaxSize, ndmMinDivision);
IRectangleTriangulationLogic logic = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogic(options);