Tests of crack calculator were added
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic of checking of input data for crack calcultor
|
||||
/// </summary>
|
||||
public class CheckCrackCalculatorInputDataLogic : ICheckInputDataLogic<CrackCalculatorInputData>
|
||||
{
|
||||
private bool result;
|
||||
private ICheckPrimitiveCollectionLogic checkPrimitiveCollectionLogic;
|
||||
|
||||
public CrackCalculatorInputData InputData { get; set; }
|
||||
|
||||
|
||||
public string CheckResult { get; private set; }
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public CheckCrackCalculatorInputDataLogic(ICheckPrimitiveCollectionLogic checkPrimitiveCollectionLogic)
|
||||
{
|
||||
this.checkPrimitiveCollectionLogic = checkPrimitiveCollectionLogic;
|
||||
}
|
||||
|
||||
public CheckCrackCalculatorInputDataLogic() : this (new CheckPrimitiveCollectionLogic())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug);
|
||||
result = true;
|
||||
CheckResult = string.Empty;
|
||||
CheckPrimitives();
|
||||
CheckActions();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CheckPrimitives()
|
||||
{
|
||||
if (checkPrimitiveCollectionLogic is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": check primitive logic");
|
||||
}
|
||||
checkPrimitiveCollectionLogic.HasPrimitives = InputData;
|
||||
checkPrimitiveCollectionLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger();
|
||||
if (checkPrimitiveCollectionLogic.Check() == false)
|
||||
{
|
||||
result = false;
|
||||
CheckResult += checkPrimitiveCollectionLogic.CheckResult;
|
||||
TraceLogger?.AddMessage(checkPrimitiveCollectionLogic.CheckResult, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckActions()
|
||||
{
|
||||
if (InputData.ForceActions is null || (!InputData.ForceActions.Any()))
|
||||
{
|
||||
result = false;
|
||||
string message = "Calculator does not contain any actions\n";
|
||||
CheckResult += message;
|
||||
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CheckCrackForceCalculatorInputDataLogic : ICheckInputDataLogic<ICrackForceCalculatorInputData>
|
||||
{
|
||||
private string checkResult;
|
||||
private bool result;
|
||||
public ICrackForceCalculatorInputData InputData { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
result = true;
|
||||
if (InputData is null)
|
||||
{
|
||||
TraceMessage("InputData is null");
|
||||
return false;
|
||||
}
|
||||
if (InputData.CheckedNdmCollection is null || ! InputData.CheckedNdmCollection.Any())
|
||||
{
|
||||
result = false;
|
||||
TraceMessage("Checked ndm collection is null or empty");
|
||||
}
|
||||
if (InputData.SectionNdmCollection is null || !InputData.SectionNdmCollection.Any())
|
||||
{
|
||||
result = false;
|
||||
TraceMessage("Section ndm collection is null or empty");
|
||||
}
|
||||
if (InputData.StartTuple is null)
|
||||
{
|
||||
result = false;
|
||||
TraceMessage("Start force tuple is null");
|
||||
}
|
||||
if (InputData.EndTuple is null)
|
||||
{
|
||||
result = false;
|
||||
TraceMessage("End force tuple is null");
|
||||
}
|
||||
if (InputData.StartTuple == InputData.EndTuple)
|
||||
{
|
||||
result = false;
|
||||
TraceMessage("Start tuple is equal to end tuple");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TraceMessage(string errorString)
|
||||
{
|
||||
checkResult += errorString + "\n";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CheckCrackWidthSP63InputDataLogic : ICheckInputDataLogic<CrackWidthLogicInputDataSP63>
|
||||
{
|
||||
private string checkResult;
|
||||
private bool result;
|
||||
|
||||
public CrackWidthLogicInputDataSP63 InputData { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public CheckCrackWidthSP63InputDataLogic(IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
this.TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public CheckCrackWidthSP63InputDataLogic() :this(null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
result = true;
|
||||
checkResult = string.Empty;
|
||||
string errorString;
|
||||
if (InputData.LengthBetweenCracks <= 0d)
|
||||
{
|
||||
errorString = ErrorStrings.DataIsInCorrect + $": length between cracks Lcrc={InputData.LengthBetweenCracks} must be greater than zero";
|
||||
TraceMessage(errorString);
|
||||
result = false;
|
||||
}
|
||||
if (InputData.TermFactor <= 0d)
|
||||
{
|
||||
errorString = ErrorStrings.DataIsInCorrect + $": Term factor fi1 {InputData.TermFactor} must be greater than zero";
|
||||
TraceMessage(errorString);
|
||||
result = false;
|
||||
}
|
||||
if (InputData.BondFactor <= 0d)
|
||||
{
|
||||
errorString = ErrorStrings.DataIsInCorrect + $": Bond factor fi2 {InputData.BondFactor} must be greater than zero";
|
||||
TraceMessage(errorString);
|
||||
result = false;
|
||||
}
|
||||
if (InputData.StressStateFactor <= 0d)
|
||||
{
|
||||
errorString = ErrorStrings.DataIsInCorrect + $": Stress factor fi3 factor {InputData.StressStateFactor} must be greater than zero";
|
||||
TraceMessage(errorString);
|
||||
result = false;
|
||||
}
|
||||
if (InputData.PsiSFactor <= 0d)
|
||||
{
|
||||
errorString = ErrorStrings.DataIsInCorrect + $": PsiS factor {InputData.PsiSFactor} must be greater than zero";
|
||||
TraceMessage(errorString);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TraceMessage(string errorString)
|
||||
{
|
||||
checkResult += errorString + "\n";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CheckRebarCrackCalculatorInputDataLogic : ICheckInputDataLogic<IRebarCrackCalculatorInputData>
|
||||
{
|
||||
private string checkResult;
|
||||
private bool result;
|
||||
|
||||
public IRebarCrackCalculatorInputData InputData { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
result = true;
|
||||
checkResult = string.Empty;
|
||||
if (InputData is null)
|
||||
{
|
||||
TraceMessage(ErrorStrings.ParameterIsNull + ": input data");
|
||||
result = false;
|
||||
}
|
||||
if (InputData.LongRebarData is null)
|
||||
{
|
||||
TraceMessage(ErrorStrings.ParameterIsNull + ": long term input data for rebar");
|
||||
result = false;
|
||||
}
|
||||
if (InputData.ShortRebarData is null)
|
||||
{
|
||||
TraceMessage(ErrorStrings.ParameterIsNull + ": short term input data for rebar");
|
||||
result = false;
|
||||
}
|
||||
if (InputData.RebarPrimitive is null)
|
||||
{
|
||||
TraceMessage(ErrorStrings.ParameterIsNull + ": rebar primitive");
|
||||
result = false;
|
||||
}
|
||||
if (InputData.UserCrackInputData is null)
|
||||
{
|
||||
TraceMessage(ErrorStrings.ParameterIsNull + ": user crack input data");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TraceMessage(string errorString)
|
||||
{
|
||||
checkResult += errorString + "\n";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class CheckTupleCalculatorInputDataLogic : ICheckInputDataLogic<TupleCrackInputData>
|
||||
{
|
||||
const string userDataIsNull = "User crack input data is null";
|
||||
private const string CollectionOfPrimitivesIsNull = "Collection does not have any primitives";
|
||||
private string? checkResult;
|
||||
|
||||
private bool result;
|
||||
/// <inheritdoc/>
|
||||
public TupleCrackInputData InputData { get; set; }
|
||||
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
result = true;
|
||||
checkResult = string.Empty;
|
||||
if (InputData is null)
|
||||
{
|
||||
result = false;
|
||||
string v = ErrorStrings.ParameterIsNull + ": InputData";
|
||||
checkResult += v;
|
||||
TraceLogger?.AddMessage(v, TraceLogStatuses.Error);
|
||||
return false;
|
||||
}
|
||||
CheckPrimitives();
|
||||
CheckUserData();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CheckPrimitives()
|
||||
{
|
||||
if (InputData.Primitives is null || !InputData.Primitives.Any())
|
||||
{
|
||||
result = false;
|
||||
checkResult += CollectionOfPrimitivesIsNull;
|
||||
TraceLogger?.AddMessage(CollectionOfPrimitivesIsNull, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckUserData()
|
||||
{
|
||||
if (InputData.UserCrackInputData is null)
|
||||
{
|
||||
result = false;
|
||||
checkResult += userDataIsNull;
|
||||
TraceLogger?.AddMessage(userDataIsNull, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user