Add Cross-section repositort tests

This commit is contained in:
Evgeny Redikultsev
2024-12-07 16:52:18 +05:00
parent 59b989ca89
commit ccaf9a927c
10 changed files with 588 additions and 107 deletions

View File

@@ -0,0 +1,36 @@
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Creates deep copy of internal elements of object which has calculators
/// </summary>
public class HasForceActionUpdateCloningStrategy : IUpdateStrategy<IHasForceActions>
{
private ICloningStrategy cloningStrategy;
public HasForceActionUpdateCloningStrategy(ICloningStrategy cloningStrategy)
{
this.cloningStrategy = cloningStrategy;
}
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
{
CheckObject.IsNull(cloningStrategy);
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.ForceActions.Clear();
foreach (var force in sourceObject.ForceActions)
{
var newForce = cloningStrategy.Clone(force);
targetObject.ForceActions.Add(newForce);
}
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IGetUpdateStrategy<T> where T : ISaveable
{
IUpdateStrategy<T> GetStrategy();
}
}