using System;
using Ringtoets.Piping.KernelWrapper.SubCalculator;
using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator;
namespace Ringtoets.Piping.KernelWrapper.TestUtil
{
///
/// This class can be used to set a temporary
/// for while testing.
/// Disposing an instance of this class will revert the
/// .
///
///
/// The following is an example for how to use this class:
///
/// using(new PipingCalculationServiceConfig()) {
/// var testFactory = (TestPipingSubCalculatorFactory) PipingCalculationService.SubCalculatorFactory;
///
/// // Perform tests with testFactory
/// }
///
///
public class PipingSubCalculatorFactoryConfig : IDisposable
{
private readonly IPipingSubCalculatorFactory previousFactory;
///
/// Creates a new instance of .
/// Sets a to
///
///
public PipingSubCalculatorFactoryConfig()
{
previousFactory = PipingSubCalculatorFactory.Instance;
PipingSubCalculatorFactory.Instance = new TestPipingSubCalculatorFactory();
}
///
/// Reverts the to the value
/// it had at time of construction of the .
///
public void Dispose()
{
PipingSubCalculatorFactory.Instance = previousFactory;
}
}
}