Добавил тесты библиотеки

This commit is contained in:
Evgeny Redikultsev
2022-06-19 20:57:08 +05:00
parent fc4f1f1db3
commit 0695dfb917
10 changed files with 371 additions and 35 deletions

Binary file not shown.

View File

@@ -128,6 +128,8 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<Folder Include="Logics\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -5,7 +5,12 @@ VisualStudioVersion = 16.0.32002.261
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", ".\StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", "StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}"
ProjectSection(ProjectDependencies) = postProject
{23138426-7994-46A7-834D-08AFB9741A86} = {23138426-7994-46A7-834D-08AFB9741A86}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperLogics", "..\StructureHelperLogics\StructureHelperLogics\StructureHelperLogics.csproj", "{23138426-7994-46A7-834D-08AFB9741A86}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +26,10 @@ Global
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU
{23138426-7994-46A7-834D-08AFB9741A86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23138426-7994-46A7-834D-08AFB9741A86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23138426-7994-46A7-834D-08AFB9741A86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23138426-7994-46A7-834D-08AFB9741A86}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace LoaderCalculator.Tests.Infrastructures.Logics
{
internal static class ExpectedProcessor
{
internal static double GetAccuracyForExpectedValue(double expectedValue, double accuracy = 0.001d)
{
if (expectedValue == 0d) { return 1.0e-15d; }
else return Math.Abs(expectedValue) * accuracy;
}
}
}

View File

@@ -0,0 +1,184 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Ndms.Transformations;
using LoaderCalculator.Data.Planes;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Infrastructure;
using LoaderCalculator.Tests.Infrastructures.Logics;
using LoaderCalculator.Triangulations;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace LoaderCalculator.Tests.FunctionalTests.SectionTests
{
public class RCSectionTest
{
private IMaterialOptions _reinforcementOptions;
private IMaterialBuilder _reinforcementBuilder;
private IBuilderDirector _reinforcementDirector;
private IMaterialOptions _concreteOptions;
private IMaterialBuilder _concreteBuilder;
private IBuilderDirector _concreteDirector;
[SetUp]
public void Setup()
{
_reinforcementOptions = new ReinforcementOptions();
_reinforcementBuilder = new ReinforcementBuilder(_reinforcementOptions);
_reinforcementDirector = new BuilderDirector(_reinforcementBuilder);
_concreteOptions = new ConcreteOptions();
_concreteBuilder = new ConcreteBuilder(_concreteOptions);
_concreteDirector = new BuilderDirector(_concreteBuilder);
}
//Theoretical limit momemt Mx = 43kN*m
[TestCase(0.000113, 0.000494, 10e3, 0d, 0d, 0.00084665917358052976d, 0.0d, 0.00020754144937701132d)]
[TestCase(0.000113, 0.000494, 40e3, 0d, 0d, 0.0033939850380287412d, 0d, 0.00082989880025069202d)]
[TestCase(0.000113, 0.000494, 42e3, 0d, 0d, 0.0056613831873867241d, 0d, 0.0014291081844183839d)]
//Theoretical limit momemt Mx = -187kN*m
[TestCase(0.000113, 0.000494, -50e3, 0d, 0d, -0.0011229555729294297d, 0d, 0.00021353225742956321d)]
[TestCase(0.000113, 0.000494, -180e3, 0d, 0d, -0.0098365950945499738d, 0d, 0.0022035516889170013d)]
[TestCase(0.000113, 0.000494, -183e3, 0d, 0d, -0.021718635290382458d, 0d, 0.0053526701372818789d)]
public void Run_ShouldPass(double topArea, double bottomArea, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
double width = 0.4;
double height = 0.6;
ArrangeMaterial(LimitStates.Collapse, true);
List<INdm> ndmList = new List<INdm>();
ndmList.AddRange(GetConcreteNdms(width, height));
ndmList.AddRange(GetReinforcementNdms(width, height, topArea, bottomArea));
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));
}
//Longitudenal prestrain only
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0d, 0d, 0.0d, 0d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.001d, 0d, 0.0d, -4.410e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.0015d, 0d, 0.0d, -6.666e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.002d, 0d, 0.0d, -8.131e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.003d, 0d, 0.0d, -8.131e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, -0.001d, 0d, 0.0d, 0.001d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, -0.002d, 0d, 0.0d, 0.002d)]
//Curvature prestrain only
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, -1e-5d, 0d, 0d, 5.4638e-6d, 0.0d, 1.069e-06d)]
//Test shows that prestrain and external forces are neglegiate one by another
[TestCase(0.000494, 0.000494, 0d, 0d, 3.952e5d, 0d, 0d, 0.001d, 0d, 0.0d, 0d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 6.873e5d, 0d, 0d, 0.002d, 0d, 0.0d, -1.703e-8d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 6.873e5d, 0d, 0d, 0.003d, 0d, 0.0d, -3.796e-8d)]
public void Run_ShouldPassPrestrain(double topArea, double bottomArea, double mx, double my, double nz, double prestrainKx, double prestrainKy, double prestrainEpsZ, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
double width = 0.4;
double height = 0.6;
ArrangeMaterial(LimitStates.Collapse, true);
List<INdm> ndmList = new List<INdm>();
IStrainMatrix prestrainMatrix = new StrainMatrix() { Kx = prestrainKx, Ky = prestrainKy, EpsZ = prestrainEpsZ };
ndmList.AddRange(GetConcreteNdms(width, height));
var reinforcement = GetReinforcementNdms(width, height, topArea, bottomArea);
NdmTransform.SetPrestrain(reinforcement, prestrainMatrix);
ndmList.AddRange(reinforcement);
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.001,
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));
}
private void ArrangeMaterial(LimitStates limitStates, bool isShortTerm)
{
_reinforcementOptions.InitModulus = 2.0e11;
_reinforcementOptions.LimitState = limitStates;
_reinforcementOptions.IsShortTerm = isShortTerm;
_reinforcementOptions.Strength = 400.0e6;
_concreteOptions.LimitState = limitStates;
_concreteOptions.IsShortTerm = isShortTerm;
_concreteOptions.Strength = 40.0e6;
}
private IEnumerable<INdm> GetConcreteNdms(double width, double heigth)
{
IMaterial _material = _concreteDirector.BuildMaterial();
RectangleTriangulationLogicOptions logicOptions = new RectangleTriangulationLogicOptions(width, heigth, 1, 20);
var logic = Triangulation.GetLogicInstance(logicOptions);
var ndmCollection = logic.GetNdmCollection(new RectangularPlane { Material = _material });
return ndmCollection;
}
private IEnumerable<INdm> GetReinforcementNdms(double width, double heigth, double topArea, double bottomArea)
{
IMaterial _material = _reinforcementDirector.BuildMaterial();
double gap = 0.05;
var ndmCollection = new INdm[]
{
new Ndm
{
Area = topArea,
CenterX = width / 2 - gap,
CenterY = heigth / 2 - gap,
Material = _material
},
new Ndm
{
Area = topArea,
CenterX = -(width / 2 - gap),
CenterY = heigth / 2 - gap,
Material = _material
},
new Ndm
{
Area = bottomArea,
CenterX = width / 2 - gap,
CenterY = -(heigth / 2 - gap),
Material = _material
},
new Ndm
{
Area = bottomArea,
CenterX = -(width / 2 - gap),
CenterY = -(heigth / 2 - gap),
Material = _material
}
};
return ndmCollection;
}
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" /> <Import Project="..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="..\packages\NUnit.3.13.3\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -39,30 +39,51 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Compile Include="Infrastructures\Logics\ExpectedProcessor.cs" />
<HintPath>..\StructureHelper\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> <Compile Include="LibrariesTests\Ndms\RCSections\RCSectionTest.cs" />
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\StructureHelper\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestExampleClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTests\Ndms\Triangulations\RectangleTriangulationTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.5.0.0\lib\net462\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="LoaderCalculator">
<HintPath>..\Libraries\LoaderCalculator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.18.1\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<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>
<ProjectReference Include="..\..\StructureHelperLogics\StructureHelperLogics\StructureHelperLogics.csproj">
<Project>{23138426-7994-46a7-834d-08afb9741a86}</Project>
<Name>StructureHelperLogics</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" /> <Error Condition="!Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.13.3\build\NUnit.props'))" />
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" /> <Error Condition="!Exists('..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props'))" />
</Target> </Target>
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
</Project> </Project>

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StructureHelperTests</RootNamespace>
<AssemblyName>StructureHelperTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets'))" />
</Target>
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets" Condition="Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets')" />
<Import Project="..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets')" />
</Project>

View File

@@ -1,14 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace StructureHelperTests
{
[TestClass]
public class TestExampleClass
{
[TestMethod]
public void TestMethod()
{
}
}
}

View File

@@ -0,0 +1,51 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Ndms.Transformations;
using LoaderCalculator.Data.Planes;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Infrastructure;
using LoaderCalculator.Tests.Infrastructures.Logics;
using LoaderCalculator.Triangulations;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Data.Shapes;
namespace StructureHelperTests.UnitTests.Ndms.Triangulations
{
public class RectangleTriangulationTest
{
//Участок по центру
[TestCase(0d, 0d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, -0.49d, -0.49d)]
//Участок со смещением от центра
[TestCase(2d, 2d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, 1.51d, 1.51d)]
[TestCase(2d, 1d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, 1.51d, 0.51d)]
//Участок с поворотом на 1 радиан
[TestCase(0d, 0d, 1.0d, 1.0d, 1d, 0.02d, 1, 50 * 50, 0.14757265268048089d, -0.67706891243125777d)]
//Участок со смещением и поворотом на 1 радиан
[TestCase(2d, 2d, 1.0d, 1.0d, 1d, 0.02d, 1, 50 * 50, -0.45476470519903267d, 2.0864776689208147d)]
public void Run_ShouldPass (double centerX, double centerY, double width, double height, double angle, double ndmMaxSize, int ndmMinDivision, int expectedCount, double expectedFirstCenterX, double expectedFirstCenterY)
{
//Arrange
IMaterial material = new Material();
ICenter center = new Center() { CenterX = centerX, CenterY = 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);
//Act
var result = logic.GetNdmCollection(material);
//Assert
Assert.NotNull(result);
Assert.AreEqual(expectedCount, result.Count());
var firstNdm = result.First();
Assert.AreEqual(expectedFirstCenterX, firstNdm.CenterX);
Assert.AreEqual(expectedFirstCenterY, firstNdm.CenterY);
}
}
}

View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" /> <package id="Castle.Core" version="5.0.0" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" /> <package id="Moq" version="4.18.1" targetFramework="net472" />
<package id="NUnit" version="3.13.3" targetFramework="net472" />
<package id="NUnit3TestAdapter" version="4.2.1" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages> </packages>