private HoverflyRunner(ISimulationDestinationSource simulationDestinationSource, HoverflyConfig hoverflyConfig) { _hoverflyMode = HoverflyMode.Capture; _hoverfly = new Hoverfly(_hoverflyMode, hoverflyConfig); _simulationSource = null; _simulationDestinationSource = simulationDestinationSource; }
private HoverflyRunner(HoverflyMode hoverflyMode, ISimulationSource simulationSource, HoverflyConfig hoverflyConfig) { _hoverflyMode = hoverflyMode; _hoverfly = new Hoverfly(_hoverflyMode, hoverflyConfig); _simulationSource = simulationSource; _simulationDestinationSource = null; }
/// <summary> /// Instantiates a runner which runs <see cref="Hoverfly"/> in Spy mode. /// </summary> /// <param name="simulationSource">The simulation to import.</param> /// <param name="hoverflyConfig">The hoverfly configuration.</param> /// <returns>Returns <see cref="HoverflyRunner"/>.</returns> public static HoverflyRunner StartInSpyMode(ISimulationSource simulationSource, HoverflyConfig hoverflyConfig) { var hoverflyRunner = new HoverflyRunner(HoverflyMode.Spy, simulationSource, hoverflyConfig); hoverflyRunner.Start(); return(hoverflyRunner); }
/// <summary> /// Adds simulations. /// </summary> /// <param name="simulationSource">The simulation to add.</param> /// <remarks>This method can be used when a simulation is already loaded, /// and in some tests need to add more simulation without replacing the whole simulation that is already loaded. /// </remarks> public void AddSimulation(ISimulationSource simulationSource) { if (simulationSource == null) { throw new ArgumentNullException(nameof(simulationSource)); } var simulation = GetSimulation(); if (simulation == null) { Simulate(simulationSource); return; } var simulationToAdd = simulationSource.GetSimulation(); foreach (var requestPair in simulationToAdd.HoverflyData.RequestResponsePair) { simulation.HoverflyData.RequestResponsePair.Add(requestPair); } foreach (var delays in simulationToAdd.HoverflyData.GlobalActions.Delays) { simulation.HoverflyData.GlobalActions.Delays.Add(delays); } _hoverfly.ImportSimulation(simulation); }
/// <summary> /// Adds simulations. /// </summary> /// <param name="simulationSource">The simulation to add.</param> /// <remarks>This method can be used when a simulation is already loaded, /// and in some tests need to add more simulation without replacing the whole simulation that is already loaded. /// </remarks> public void AddSimulation(ISimulationSource simulationSource) { if (simulationSource == null) { throw new ArgumentNullException(nameof(simulationSource)); } _hoverfly.AddSimulation(simulationSource); }
/// <summary> /// Adds simulations. /// </summary> /// <param name="simulationSource">The simulation to add.</param> /// <remarks>This method can be used when a simulation is already loaded, /// and in some tests need to add more simulation without replacing the whole simulation that is already loaded. /// </remarks> public void AddSimulation(ISimulationSource simulationSource) { if (simulationSource == null) { throw new ArgumentNullException(nameof(simulationSource)); } AddSimulation(simulationSource.GetSimulation()); }
/// <summary> /// Changes the Simulation used by <see cref="Hoverfly"/>. /// </summary> /// <param name="simulationSource">The simulation source.</param> public void Simulate(ISimulationSource simulationSource) { if (simulationSource == null) { throw new ArgumentNullException(nameof(simulationSource)); } _simulationSource = simulationSource; ImportSimulationSource(); }
/// <summary> /// Imports hoverfly simulation data. /// </summary> /// <param name="source">The source of the simulation data to import.</param> public void ImportSimulation(ISimulationSource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } LogInfo("Importing simulation data to Hoverfly."); var simulation = source.GetSimulation(); if (simulation != null) { _hoverflyClient.ImportSimulation(simulation); } }
/// <summary> /// Instantiates a runner which runs <see cref="Hoverfly"/> in Spy mode. /// </summary> /// <param name="simulationSource">The simulation to import.</param> /// <returns>Returns <see cref="HoverflyRunner"/>.</returns> public static HoverflyRunner StartInSpyMode(ISimulationSource simulationSource) { return(StartInSpyMode(simulationSource, HoverflyConfig.Config())); }