Logics of accidental eccentricity were separated and tested

This commit is contained in:
Evgeny Redikultsev
2024-03-10 19:20:01 +05:00
parent 0a453c5a95
commit b81b7a0929
30 changed files with 885 additions and 331 deletions

View File

@@ -0,0 +1,39 @@
using Moq;
using NUnit.Framework;
using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.FunctionalTests.RCs.Eccentricitis
{
public class RcEccentricityAxisLogicTests
{
[TestCase(12d, 0.2d, 0.02d)]
[TestCase(3d, 0.9d, 0.03d)]
[TestCase(2, 0.2d, 0.01d)]
public void GetValue_ShouldCalculateCorrectly(double length, double size, double expectedEccentricity)
{
// Arrange
var loggerMock = new Mock<IShiftTraceLogger>();
var rcEccentricityAxisLogic = new RcEccentricityAxisLogic
{
Length = length,
Size = size,
TraceLogger = loggerMock.Object,
};
// Act
var result = rcEccentricityAxisLogic.GetValue();
// Assert
//loggerMock.Verify(logger => logger.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.Exactly(7)); // Adjust based on your actual calls
Assert.AreEqual(expectedEccentricity, result, 0.0001); // Adjust based on your expected result
// Add more assertions based on your expected behavior
}
}
}

View File

@@ -0,0 +1,43 @@
using Moq;
using NUnit.Framework;
using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.FunctionalTests.RCs.Eccentricitis
{
public class RcAccEccentricityLogicTests
{
[Test]
public void GetValue_ShouldCalculateCorrectly()
{
// Arrange
var eccentricityAxisLogicMock = new Mock<IRcEccentricityAxisLogic>();
eccentricityAxisLogicMock.Setup(el => el.GetValue()).Returns(3.0); // Adjust based on your expected result
var loggerMock = new Mock<IShiftTraceLogger>();
var rcAccEccentricityLogic = new RcAccEccentricityLogic(eccentricityAxisLogicMock.Object)
{
Length = 100.0,
SizeX = 5.0,
SizeY = 10.0,
TraceLogger = loggerMock.Object,
};
// Act
var result = rcAccEccentricityLogic.GetValue();
// Assert
eccentricityAxisLogicMock.Verify(el => el.GetValue(), Times.Exactly(2));
//loggerMock.Verify(logger => logger.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.Exactly(3)); // Adjust based on your actual calls
Assert.AreEqual(3.0, result.ex, 0.001); // Adjust based on your expected result
Assert.AreEqual(3.0, result.ey, 0.001); // Adjust based on your expected result
// Add more assertions based on your expected behavior
}
}
}

View File

@@ -0,0 +1,58 @@
using Moq;
using NUnit.Framework;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models.Sections;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.FunctionalTests.RCs.Eccentricitis
{
public class RcEccentricityLogicTests
{
[TestCase(30, 1.0, 2.0, -60, -30)]
[TestCase(30, 2.0, 1.0, -30, -60)]
public void GetValue_ShouldCalculateCorrectly(double nz, double ex, double ey, double expectedMx, double expectedMy)
{
// Arrange
var inputForceTuple = new ForceTuple
{
Mx = 10,
My = 20,
Nz = nz,
Qx = 40.0,
Qy = 50.0,
Mz = 60.0,
};
var eccentricityLogicMock = new Mock<IRcAccEccentricityLogic>();
eccentricityLogicMock.Setup(el => el.GetValue()).Returns((ex, ey));
var loggerMock = new Mock<IShiftTraceLogger>();
var rcEccentricityLogic = new RcEccentricityLogic(eccentricityLogicMock.Object)
{
Length = 100.0,
SizeX = 5.0,
SizeY = 10.0,
InputForceTuple = inputForceTuple,
TraceLogger = loggerMock.Object,
};
// Act
var result = rcEccentricityLogic.GetValue();
// Assert
eccentricityLogicMock.Verify(el => el.GetValue(), Times.Once);
//loggerMock.Verify(logger => logger.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.Exactly(6)); // Adjust based on your actual calls
//loggerMock.Verify(logger => logger.AddEntry(It.IsAny<string>()), Times.Once); // Adjust based on your actual calls
Assert.AreEqual(expectedMx, result.Mx, 0.001); // Adjust based on your expected result
Assert.AreEqual(expectedMy, result.My, 0.001); // Adjust based on your expected result
// Add more assertions based on your expected behavior
}
}
}

View File

@@ -7,8 +7,8 @@ namespace StructureHelperTests.UnitTests.MaterialTests
{
public class MaterialStrengthTest
{
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 347826086.95652175d, 347826086.95652175d)]
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 400000000d, 400000000d)]
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 339130434.78260875d, 339130434.78260875d)]
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 390000000d, 390000000d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 400000000.0d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 434782608.69565225d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]

View File

@@ -15,7 +15,7 @@ namespace StructureHelperTests.ViewModelTests
var labels = new List<string>();
for (int i = 0; i < columnCount; i++)
{
labels[i] = $"Column{i}";
labels.Add($"Column{i}");
}
var array = new ArrayParameter<double>(rowCount, columnCount, labels);
for (int i = 0; i < columnCount; i++)