Add beam shear analysis converting from DTO
This commit is contained in:
@@ -1,47 +1,32 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using DataAccess.DTOs.Converters;
|
||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Analyses;
|
using StructureHelperCommon.Models.Analyses;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogic.Models.Analyses;
|
using StructureHelperLogic.Models.Analyses;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
using StructureHelperLogics.Models.Analyses;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
namespace DataAccess.DTOs
|
||||||
{
|
{
|
||||||
public class AnalysisFromDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
|
public class AnalysisFromDTOConvertStrategy : ConvertStrategy<IAnalysis, IAnalysis>
|
||||||
{
|
{
|
||||||
private const string AnalysisIs = "Analysis type is";
|
private const string AnalysisIs = "Analysis type is";
|
||||||
|
|
||||||
private IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy;
|
|
||||||
private IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy;
|
private IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy;
|
||||||
|
|
||||||
public AnalysisFromDTOConvertStrategy(IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy,
|
public AnalysisFromDTOConvertStrategy()
|
||||||
IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy)
|
|
||||||
{
|
{
|
||||||
this.convertCrossSectionNdmAnalysisStrategy = convertCrossSectionNdmAnalysisStrategy;
|
|
||||||
this.versionProcessorConvertStrategy = versionProcessorConvertStrategy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnalysisFromDTOConvertStrategy() : this (new CrossSectionNdmAnalysisFromDTOConvertStrategy(),
|
public AnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||||
new VersionProcessorFromDTOConvertStrategy())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
public override IAnalysis GetNewItem(IAnalysis source)
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public IAnalysis Convert(IAnalysis source)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Check();
|
|
||||||
IAnalysis analysis = GetAnalysis(source);
|
IAnalysis analysis = GetAnalysis(source);
|
||||||
return analysis;
|
return analysis;
|
||||||
}
|
}
|
||||||
@@ -51,29 +36,51 @@ namespace DataAccess.DTOs.Converters
|
|||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IAnalysis GetAnalysis(IAnalysis source)
|
private IAnalysis GetAnalysis(IAnalysis source)
|
||||||
{
|
{
|
||||||
IAnalysis newItem;
|
|
||||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||||
{
|
{
|
||||||
newItem = GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||||
|
}
|
||||||
|
else if (source is IBeamShearAnalysis beamShearAnalysis)
|
||||||
|
{
|
||||||
|
GetBeamShearAnalysis(beamShearAnalysis);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
|
||||||
throw new StructureHelperException(errorString);
|
throw new StructureHelperException(errorString);
|
||||||
}
|
}
|
||||||
newItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
NewItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
||||||
return newItem;
|
return NewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GetBeamShearAnalysis(IBeamShearAnalysis beamShearAnalysis)
|
||||||
|
{
|
||||||
|
TraceLogger?.AddMessage(AnalysisIs + " beam shear Analysis", TraceLogStatuses.Debug);
|
||||||
|
TraceLogger?.AddMessage("Beam shear analysis converting has been started", TraceLogStatuses.Debug);
|
||||||
|
var convertStrategy = new DictionaryConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||||
|
(this, new BeamShearAnalysisFromDTOConvertStrategy(this));
|
||||||
|
NewItem = convertStrategy.Convert(beamShearAnalysis);
|
||||||
|
TraceLogger?.AddMessage("Beam shear analysis converting has been finished succesfully", TraceLogStatuses.Debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
||||||
|
{
|
||||||
|
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||||
|
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been started", TraceLogStatuses.Debug);
|
||||||
|
var convertStrategy = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||||
|
(this, new CrossSectionNdmAnalysisFromDTOConvertStrategy(this));
|
||||||
|
NewItem = convertStrategy.Convert(source);
|
||||||
|
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished successfully", TraceLogStatuses.Debug);
|
||||||
|
}
|
||||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Service);
|
||||||
|
versionProcessorConvertStrategy ??= new VersionProcessorFromDTOConvertStrategy();
|
||||||
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||||
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
|
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
|
||||||
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
|
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
|
||||||
@@ -81,22 +88,5 @@ namespace DataAccess.DTOs.Converters
|
|||||||
return versionProcessor;
|
return versionProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICrossSectionNdmAnalysis GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Service);
|
|
||||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting is started", TraceLogStatuses.Service);
|
|
||||||
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this, convertCrossSectionNdmAnalysisStrategy);
|
|
||||||
ICrossSectionNdmAnalysis crossSectionNdmAnalysis = convertLogic.Convert(source);
|
|
||||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished successfully", TraceLogStatuses.Service);
|
|
||||||
return crossSectionNdmAnalysis;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<IAnalysis, IAnalysis>(this);
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperLogics.Models.Analyses;
|
||||||
|
|
||||||
|
namespace DataAccess.DTOs
|
||||||
|
{
|
||||||
|
public class BeamShearAnalysisFromDTOConvertStrategy : ConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||||
|
{
|
||||||
|
private IUpdateStrategy<IBeamShearAnalysis> updateStrategy;
|
||||||
|
|
||||||
|
public BeamShearAnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IBeamShearAnalysis GetNewItem(IBeamShearAnalysis source)
|
||||||
|
{
|
||||||
|
ChildClass = this;
|
||||||
|
GetAnalysis(source);
|
||||||
|
return NewItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetAnalysis(IBeamShearAnalysis source)
|
||||||
|
{
|
||||||
|
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||||
|
BeamShearAnalysis beamShearAnalysis = new(source.Id);
|
||||||
|
updateStrategy.Update(beamShearAnalysis, source);
|
||||||
|
NewItem = beamShearAnalysis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,62 +10,34 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DataAccess.DTOs
|
namespace DataAccess.DTOs
|
||||||
{
|
{
|
||||||
public class DateVersionFromDTOConvertStrategy : IConvertStrategy<IDateVersion, IDateVersion>
|
public class DateVersionFromDTOConvertStrategy : ConvertStrategy<IDateVersion, IDateVersion>
|
||||||
{
|
{
|
||||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||||
private DictionaryConvertStrategy<ISaveable, ISaveable> convertLogic;
|
private IConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||||
|
|
||||||
public DateVersionFromDTOConvertStrategy(IUpdateStrategy<IDateVersion> updateStrategy,
|
public override IDateVersion GetNewItem(IDateVersion source)
|
||||||
IConvertStrategy<ISaveable, ISaveable> convertStrategy)
|
|
||||||
{
|
{
|
||||||
this.updateStrategy = updateStrategy;
|
ChildClass = this;
|
||||||
this.convertStrategy = convertStrategy;
|
return GetDateVersion(source);
|
||||||
}
|
|
||||||
|
|
||||||
public DateVersionFromDTOConvertStrategy() : this (
|
|
||||||
new DateVersionUpdateStrategy(),
|
|
||||||
new VersionItemFromDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public IDateVersion Convert(IDateVersion source)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
return GetDateVersion(source);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateVersion GetDateVersion(IDateVersion source)
|
private DateVersion GetDateVersion(IDateVersion source)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Service);
|
||||||
|
InitializeStrategies();
|
||||||
DateVersion newItem = new(source.Id);
|
DateVersion newItem = new(source.Id);
|
||||||
updateStrategy.Update(newItem, source);
|
updateStrategy.Update(newItem, source);
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>(this, convertStrategy);
|
|
||||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
||||||
TraceLogger?.AddMessage($"Date version date = {newItem.DateTime} converting has been finished", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage($"Date version date = {newItem.DateTime} converting has been finished", TraceLogStatuses.Service);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check()
|
private void InitializeStrategies()
|
||||||
{
|
{
|
||||||
var checkLogic = new CheckConvertLogic<IDateVersion, IDateVersion>(this);
|
updateStrategy ??= new DateVersionUpdateStrategy();
|
||||||
checkLogic.Check();
|
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>
|
||||||
|
(this, new VersionItemFromDTOConvertStrategy(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,34 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogic.Models.Analyses;
|
using StructureHelperLogic.Models.Analyses;
|
||||||
using StructureHelperLogics.Models.Analyses;
|
using StructureHelperLogics.Models.Analyses;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
namespace DataAccess.DTOs.Converters
|
||||||
{
|
{
|
||||||
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : ConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||||
{
|
{
|
||||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
||||||
|
|
||||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy)
|
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||||
{
|
{
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy())
|
public override ICrossSectionNdmAnalysis GetNewItem(ICrossSectionNdmAnalysis source)
|
||||||
{
|
{
|
||||||
|
ChildClass = this;
|
||||||
|
GetAnalysis(source);
|
||||||
|
return NewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
private void GetAnalysis(ICrossSectionNdmAnalysis source)
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public ICrossSectionNdmAnalysis Convert(ICrossSectionNdmAnalysis source)
|
|
||||||
{
|
{
|
||||||
try
|
TraceLogger?.AddMessage("Cross-section analysis converting has been started");
|
||||||
{
|
updateStrategy ??= new CrossSectionNdmAnalysisUpdateStrategy();
|
||||||
Check();
|
NewItem = new CrossSectionNdmAnalysis(source.Id);
|
||||||
ICrossSectionNdmAnalysis newItem = GetCrossSectionNDMAnalysis(source);
|
updateStrategy.Update(NewItem, source);
|
||||||
return newItem;
|
TraceLogger?.AddMessage("Cross-section analysis has been finished successfully");
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICrossSectionNdmAnalysis GetCrossSectionNDMAnalysis(ICrossSectionNdmAnalysis source)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage("Cross-section sonverting is started");
|
|
||||||
CrossSectionNdmAnalysis newItem = new(source.Id);
|
|
||||||
updateStrategy.Update(newItem, source);
|
|
||||||
TraceLogger?.AddMessage("Cross-section analysis was obtained successfully");
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this);
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace DataAccess.DTOs
|
|||||||
|
|
||||||
public override Project GetNewItem(ProjectDTO source)
|
public override Project GetNewItem(ProjectDTO source)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage("Converting of project is started");
|
TraceLogger?.AddMessage("Converting of project has been started");
|
||||||
Project newItem = new(source.Id);
|
Project newItem = new(source.Id);
|
||||||
List<IVisualAnalysis> analyses = GetAnalyses(source, newItem);
|
List<IVisualAnalysis> analyses = GetAnalyses(source, newItem);
|
||||||
newItem.VisualAnalyses.Clear();
|
newItem.VisualAnalyses.Clear();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace DataAccess.DTOs
|
|||||||
public class ProjectToDTOConvertStrategy : ConvertStrategy<ProjectDTO, IProject>
|
public class ProjectToDTOConvertStrategy : ConvertStrategy<ProjectDTO, IProject>
|
||||||
{
|
{
|
||||||
private IUpdateStrategy<IProject> updateStrategy;
|
private IUpdateStrategy<IProject> updateStrategy;
|
||||||
private DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
||||||
|
|
||||||
|
|
||||||
public ProjectToDTOConvertStrategy()
|
public ProjectToDTOConvertStrategy()
|
||||||
@@ -17,7 +17,7 @@ namespace DataAccess.DTOs
|
|||||||
|
|
||||||
public ProjectToDTOConvertStrategy(
|
public ProjectToDTOConvertStrategy(
|
||||||
IUpdateStrategy<IProject> updateStrategy,
|
IUpdateStrategy<IProject> updateStrategy,
|
||||||
DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic)
|
IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic)
|
||||||
{
|
{
|
||||||
this.updateStrategy = updateStrategy;
|
this.updateStrategy = updateStrategy;
|
||||||
this.convertLogic = convertLogic;
|
this.convertLogic = convertLogic;
|
||||||
@@ -41,9 +41,7 @@ namespace DataAccess.DTOs
|
|||||||
{
|
{
|
||||||
updateStrategy ??= new ProjectUpdateStrategy();
|
updateStrategy ??= new ProjectUpdateStrategy();
|
||||||
convertLogic ??= new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
convertLogic ??= new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
||||||
(this,
|
(this, new VisualAnalysisToDTOConvertStrategy(this));
|
||||||
new VisualAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,24 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
namespace DataAccess.DTOs
|
||||||
{
|
{
|
||||||
public class VersionItemFromDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
public class VersionItemFromDTOConvertStrategy : ConvertStrategy<ISaveable, ISaveable>
|
||||||
{
|
{
|
||||||
private const string AnalysisIs = "Analysis type is";
|
private const string AnalysisIs = "Analysis type is";
|
||||||
private IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy;
|
private IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy;
|
||||||
|
|
||||||
public VersionItemFromDTOConvertStrategy(IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy)
|
public VersionItemFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||||
{
|
{
|
||||||
this.crossSectionConvertStrategy = crossSectionConvertStrategy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VersionItemFromDTOConvertStrategy() : this (new CrossSectionFromDTOConvertStrategy())
|
public override ISaveable GetNewItem(ISaveable source)
|
||||||
{
|
{
|
||||||
|
ChildClass = this;
|
||||||
}
|
return GetNewAnalysis(source);
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public ISaveable Convert(ISaveable source)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
return GetNewAnalysis(source);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISaveable GetNewAnalysis(ISaveable source)
|
private ISaveable GetNewAnalysis(ISaveable source)
|
||||||
@@ -46,6 +28,10 @@ namespace DataAccess.DTOs
|
|||||||
{
|
{
|
||||||
newItem = ProcessCrossSection(crossSection);
|
newItem = ProcessCrossSection(crossSection);
|
||||||
}
|
}
|
||||||
|
else if (source is IBeamShear beamShear)
|
||||||
|
{
|
||||||
|
newItem = ProcessBeamShear(beamShear);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||||
@@ -56,10 +42,16 @@ namespace DataAccess.DTOs
|
|||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ISaveable ProcessBeamShear(IBeamShear beamShear)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
private ICrossSection ProcessCrossSection(ICrossSection source)
|
private ICrossSection ProcessCrossSection(ICrossSection source)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service);
|
||||||
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
||||||
|
crossSectionConvertStrategy ??= new CrossSectionFromDTOConvertStrategy();
|
||||||
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||||
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
||||||
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
|
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
|
||||||
@@ -67,11 +59,5 @@ namespace DataAccess.DTOs
|
|||||||
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>(this);
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,45 +10,20 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DataAccess.DTOs
|
namespace DataAccess.DTOs
|
||||||
{
|
{
|
||||||
public class VersionProcessorFromDTOConvertStrategy : IConvertStrategy<IVersionProcessor, IVersionProcessor>
|
public class VersionProcessorFromDTOConvertStrategy : ConvertStrategy<IVersionProcessor, IVersionProcessor>
|
||||||
{
|
{
|
||||||
private IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy;
|
private IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy;
|
||||||
private ICheckConvertLogic<IVersionProcessor, IVersionProcessor> checkLogic;
|
|
||||||
|
|
||||||
public VersionProcessorFromDTOConvertStrategy(
|
public override IVersionProcessor GetNewItem(IVersionProcessor source)
|
||||||
IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy)
|
|
||||||
{
|
{
|
||||||
this.dateVersionConvertStrategy = dateVersionConvertStrategy;
|
ChildClass = this;
|
||||||
this.checkLogic = checkLogic;
|
return GetVersionProcessor(source);
|
||||||
}
|
|
||||||
|
|
||||||
public VersionProcessorFromDTOConvertStrategy() : this(new DateVersionFromDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public IVersionProcessor Convert(IVersionProcessor source)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
IVersionProcessor versionProcessor = GetVersionProcessor(source);
|
|
||||||
return versionProcessor;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Debug);
|
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Debug);
|
||||||
|
dateVersionConvertStrategy ??= new DateVersionFromDTOConvertStrategy();
|
||||||
IVersionProcessor newItem = new VersionProcessor(source.Id);
|
IVersionProcessor newItem = new VersionProcessor(source.Id);
|
||||||
TraceLogger?.AddMessage($"Source version processor has {source.Versions.Count} version(s)", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage($"Source version processor has {source.Versions.Count} version(s)", TraceLogStatuses.Service);
|
||||||
dateVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
dateVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||||
@@ -62,11 +37,5 @@ namespace DataAccess.DTOs
|
|||||||
TraceLogger?.AddMessage("Version processor has been converted successfully", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage("Version processor has been converted successfully", TraceLogStatuses.Service);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<IVersionProcessor, IVersionProcessor>(this);
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ namespace DataAccess.DTOs
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VisualAnalysisToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private VisualAnalysisDTO GetNewAnalysis(IVisualAnalysis source)
|
private VisualAnalysisDTO GetNewAnalysis(IVisualAnalysis source)
|
||||||
{
|
{
|
||||||
InitializeStrategies();
|
InitializeStrategies();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace DataAccess.DTOs
|
|||||||
public class ProjectDTO : IProject
|
public class ProjectDTO : IProject
|
||||||
{
|
{
|
||||||
[JsonProperty("Id")]
|
[JsonProperty("Id")]
|
||||||
public Guid Id { get;}
|
public Guid Id { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string FullFileName { get; set; }
|
public string FullFileName { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
@@ -27,5 +27,10 @@ namespace DataAccess.DTOs
|
|||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectDTO() : this(Guid.NewGuid())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
namespace DataAccess.DTOs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ using StructureHelperLogics.Models.Analyses;
|
|||||||
using StructureHelperLogics.Models.BeamShears;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainWindow
|
namespace StructureHelper.Windows.MainWindow
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using LoaderCalculator;
|
using StructureHelper.Infrastructure;
|
||||||
using StructureHelper.Infrastructure;
|
|
||||||
using StructureHelper.Infrastructure.Enums;
|
using StructureHelper.Infrastructure.Enums;
|
||||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
|
using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
|
||||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||||
@@ -14,7 +13,6 @@ using StructureHelperLogics.Models.CrossSections;
|
|||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
||||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using MessageBox = System.Windows.Forms.MessageBox;
|
using MessageBox = System.Windows.Forms.MessageBox;
|
||||||
@@ -210,7 +208,10 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
|||||||
ProcessResult();
|
ProcessResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TraceDocumentService.ShowDocument(SelectedItem.TraceLogger.TraceLoggerEntries);
|
if (SelectedItem.ShowTraceData == true)
|
||||||
|
{
|
||||||
|
TraceDocumentService.ShowDocument(SelectedItem.TraceLogger.TraceLoggerEntries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowInteractionDiagramByInputData(LimitCurvesCalculator calculator)
|
private void ShowInteractionDiagramByInputData(LimitCurvesCalculator calculator)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -40,6 +41,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
public IShiftTraceLogger TraceLogger { get; set; }
|
||||||
|
|
||||||
public T NewItem { get; set; }
|
public T NewItem { get; set; }
|
||||||
|
public ConvertStrategy<T, V> ChildClass { get; set; }
|
||||||
|
|
||||||
public virtual T Convert(V source)
|
public virtual T Convert(V source)
|
||||||
{
|
{
|
||||||
@@ -48,12 +50,18 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
Check();
|
Check();
|
||||||
TraceStartOfConverting(source);
|
TraceStartOfConverting(source);
|
||||||
T target = GetNewItem(source);
|
T target = GetNewItem(source);
|
||||||
|
if (target is null)
|
||||||
|
{
|
||||||
|
string errorString = ErrorStrings.ParameterIsNull + ": result of converting";
|
||||||
|
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||||
|
throw new StructureHelperException(errorString);
|
||||||
|
}
|
||||||
TraceFinishOfConverting(target);
|
TraceFinishOfConverting(target);
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
TraceLogger?.AddMessage(LoggerStrings.LogicType(ChildClass ?? this), TraceLogStatuses.Error);
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@@ -76,7 +84,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
}
|
}
|
||||||
private void TraceFinishOfConverting(ISaveable saveable)
|
private void TraceFinishOfConverting(ISaveable saveable)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
|
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using StructureHelperCommon.Models.Forces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
|
||||||
using StructureHelperLogics.Models.BeamShears;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
|
|
||||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
namespace YourNamespace.Tests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class GetDirectShearForceLogicTests
|
|
||||||
{
|
|
||||||
private Mock<IShiftTraceLogger> _mockLogger;
|
|
||||||
private Mock<ISumForceByShearLoadLogic> _mockSummaryForceLogic;
|
|
||||||
private GetDirectShearForceLogic _logic;
|
|
||||||
|
|
||||||
[SetUp]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
|
||||||
_mockSummaryForceLogic = new Mock<ISumForceByShearLoadLogic>();
|
|
||||||
var mockAction = new Mock<IBeamShearAction>();
|
|
||||||
var mockInclinedSection = new Mock<IInclinedSection>();
|
|
||||||
var mockShearLoad = new Mock<IBeamSpanLoad>();
|
|
||||||
|
|
||||||
mockAction.Setup(a => a.SupportAction.SupportForce.ForceTuple.Qx).Returns(100.0);
|
|
||||||
mockAction.Setup(a => a.SupportAction.ShearLoads).Returns(new List<IBeamSpanLoad> { mockShearLoad.Object });
|
|
||||||
|
|
||||||
mockInclinedSection.Setup(i => i.StartCoord).Returns(2.0);
|
|
||||||
mockInclinedSection.Setup(i => i.EndCoord).Returns(5.0);
|
|
||||||
|
|
||||||
_mockSummaryForceLogic.Setup(s => s.GetSumShearForce(mockShearLoad.Object, 2.0, 5.0)).Returns(new ForceTuple() { Qy = 50.0});
|
|
||||||
_logic = new GetDirectShearForceLogic(mockAction.Object, mockInclinedSection.Object, LimitStates.ULS, CalcTerms.ShortTerm, _mockLogger.Object, _mockSummaryForceLogic.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void GetShearForce_ShouldReturnCorrectShearForce()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
double result = _logic.CalculateShearForceTuple().Qy;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.That(result, Is.EqualTo(150.0));
|
|
||||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
|||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperLogics.Models.BeamShears;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
|
||||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||||
{
|
{
|
||||||
@@ -12,25 +13,33 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
{
|
{
|
||||||
private Mock<IShiftTraceLogger> _mockLogger;
|
private Mock<IShiftTraceLogger> _mockLogger;
|
||||||
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
||||||
|
private Mock<IFactoredCombinationProperty> _mockCombination;
|
||||||
private SumConcentratedForceLogic _logic;
|
private SumConcentratedForceLogic _logic;
|
||||||
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||||
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
||||||
|
_mockCombination = new Mock<IFactoredCombinationProperty>();
|
||||||
_logic = new SumConcentratedForceLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
_logic = new SumConcentratedForceLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidConcentratedForce()
|
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidConcentratedForce()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
_mockCombination.Setup(f => f.LimitState).Returns(LimitStates.ULS);
|
||||||
|
_mockCombination.Setup(f => f.CalcTerm).Returns(CalcTerms.ShortTerm);
|
||||||
|
_mockCombination.Setup(f => f.LongTermFactor).Returns(0.9);
|
||||||
|
_mockCombination.Setup(f => f.ULSFactor).Returns(1.2);
|
||||||
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
||||||
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(3.0);
|
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(3.0);
|
||||||
mockConcentratedForce.Setup(f => f.ForceValue).Returns(new ForceTuple() { Qy = 100.0 });
|
mockConcentratedForce.Setup(f => f.ForceValue).Returns(new ForceTuple() { Qy = 100.0 });
|
||||||
mockConcentratedForce.Setup(f => f.LoadRatio).Returns(0.8);
|
mockConcentratedForce.Setup(f => f.LoadRatio).Returns(0.8);
|
||||||
mockConcentratedForce.Setup(f => f.RelativeLoadLevel).Returns(0.5);
|
mockConcentratedForce.Setup(f => f.RelativeLoadLevel).Returns(0.5);
|
||||||
|
mockConcentratedForce.Setup(f => f.CombinationProperty).Returns(_mockCombination.Object);
|
||||||
|
|
||||||
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(3.5);
|
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(3.5);
|
||||||
|
|
||||||
@@ -38,7 +47,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.That(result, Is.EqualTo(80.0));
|
Assert.That(result, Is.EqualTo(72.000000000000014d));
|
||||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +56,9 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
||||||
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(6.0);
|
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(6.0);
|
||||||
|
mockConcentratedForce.Setup(f => f.ForceValue).Returns(new ForceTuple() { Qy = 100.0 });
|
||||||
|
mockConcentratedForce.Setup(f => f.Name).Returns("Zero_name");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
|||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperLogics.Models.BeamShears;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
|
||||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||||
{
|
{
|
||||||
@@ -13,25 +14,32 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
private Mock<IShiftTraceLogger> _mockLogger;
|
private Mock<IShiftTraceLogger> _mockLogger;
|
||||||
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
||||||
private SumDistributedLoadLogic _logic;
|
private SumDistributedLoadLogic _logic;
|
||||||
|
private Mock<IFactoredCombinationProperty> _mockCombination;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||||
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
||||||
_logic = new SumDistributedLoadLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
_mockCombination = new Mock<IFactoredCombinationProperty>();
|
||||||
|
_logic = new SumDistributedLoadLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidDistributedLoad()
|
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidDistributedLoad()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
_mockCombination.Setup(f => f.LimitState).Returns(LimitStates.ULS);
|
||||||
|
_mockCombination.Setup(f => f.CalcTerm).Returns(CalcTerms.ShortTerm);
|
||||||
|
_mockCombination.Setup(f => f.LongTermFactor).Returns(0.9);
|
||||||
|
_mockCombination.Setup(f => f.ULSFactor).Returns(1.2);
|
||||||
|
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
||||||
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(1.0);
|
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(1.0);
|
||||||
mockDistributedLoad.Setup(d => d.EndCoordinate).Returns(4.0);
|
mockDistributedLoad.Setup(d => d.EndCoordinate).Returns(4.0);
|
||||||
mockDistributedLoad.Setup(d => d.LoadValue).Returns(new ForceTuple() { Qy = 50.0 });
|
mockDistributedLoad.Setup(d => d.LoadValue).Returns(new ForceTuple() { Qy = 50.0 });
|
||||||
mockDistributedLoad.Setup(d => d.LoadRatio).Returns(0.9);
|
mockDistributedLoad.Setup(d => d.LoadRatio).Returns(0.9);
|
||||||
mockDistributedLoad.Setup(d => d.RelativeLoadLevel).Returns(0.5);
|
mockDistributedLoad.Setup(d => d.RelativeLoadLevel).Returns(0.5);
|
||||||
|
mockDistributedLoad.Setup(d => d.CombinationProperty).Returns(_mockCombination.Object);
|
||||||
|
|
||||||
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(4.5);
|
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(4.5);
|
||||||
|
|
||||||
@@ -39,7 +47,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.That(result, Is.EqualTo(135.0));
|
Assert.That(result, Is.EqualTo(121.50000000000001d));
|
||||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +57,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
||||||
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(6.0);
|
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(6.0);
|
||||||
|
mockDistributedLoad.Setup(d => d.LoadValue.Qy).Returns(100);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
||||||
|
|||||||
Reference in New Issue
Block a user