private HoverflyRunner(HoverflyMode hoverflyMode, ISimulationSource simulationSource, HoverflyConfig hoverflyConfig)
 {
     _hoverflyMode                = hoverflyMode;
     _hoverfly                    = new Hoverfly(_hoverflyMode, hoverflyConfig);
     _simulationSource            = simulationSource;
     _simulationDestinationSource = null;
 }
 private HoverflyRunner(ISimulationDestinationSource simulationDestinationSource, HoverflyConfig hoverflyConfig)
 {
     _hoverflyMode                = HoverflyMode.Capture;
     _hoverfly                    = new Hoverfly(_hoverflyMode, hoverflyConfig);
     _simulationSource            = null;
     _simulationDestinationSource = simulationDestinationSource;
 }
        /// <summary>
        /// Changes the hoverfly mode.
        /// </summary>
        /// <param name="mode">The <see cref="HoverflyMode"/> to change to.</param>
        public void ChangeMode(HoverflyMode mode)
        {
            var modeBody = new StringContent("{ \"mode\": \"" + mode.ToString().ToLower() + "\"}", Encoding.UTF8, "application/json");

            using (var response = Task.Run(() => _hoverflyHttpClient.PutAsync(HOVERFLY_MODE_PATH, modeBody)).Result)
            {
                if (!response.IsSuccessStatusCode)
                {
                    throw new HttpRequestException($"Can't change the mode to {mode}, status code: '{response.StatusCode}', reason '{response.ReasonPhrase}'");
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Provide access to Hoverfly to start and stop simulation or capture HTTP calls.
        /// </summary>
        /// <param name="hoverflyMode">The <see cref="HoverflyMode"/> Hoverfly should be started in. Default is Simulate if nothing is specified.</param>
        /// <param name="config">Hoverfly configurations. <see cref="HoverflyConfig"/></param>
        /// <param name="hoverflyClient">Hoverfly client, by default the <see cref="HoverflyClient"/> is used to accessing the Hoverfly process REST API.</param>
        public Hoverfly(
            HoverflyMode hoverflyMode      = HoverflyMode.Simulate,
            HoverflyConfig config          = null,
            IHoverflyClient hoverflyClient = null)
        {
            _hoverflyMode = hoverflyMode;

            _hoverflyConfig = config ?? HoverflyConfig.Config();

            _hoverflyClient = hoverflyClient ?? new HoverflyClient(
                new Uri($"{_hoverflyConfig.RemoteHost}:{_hoverflyConfig.AdminPort}"),
                _hoverflyConfig.Logger);
        }
Esempio n. 5
0
        /// <summary>
        /// Provide access to Hoverfly to start and stop simulation or capture HTTP calls.
        /// </summary>
        /// <param name="hoverflyMode">The <see cref="HoverflyMode"/> Hoverfly should be started in. Default is Simulate if nothing is specified.</param>
        /// <param name="config">Hoverfly configurations. <see cref="HoverflyConfig"/></param>
        /// <param name="loggerFactory">A logger factory for creating a logger to log messages.</param>
        /// <param name="hoverflyClient">Hoverfly client, by default the <see cref="HoverflyClient"/> is used to accessing the Hoverfly process REST API.</param>
        public Hoverfly(
            HoverflyMode hoverflyMode      = HoverflyMode.Simulate,
            HoverflyConfig config          = null,
            ILoggerFactory loggerFactory   = null,
            IHoverflyClient hoverflyClient = null)
        {
            _hoverflyMode = hoverflyMode;

            _hoverflyConfig = config ?? HoverflyConfig.Config();

            _logger = loggerFactory?.Create(GetType().Name);

            _hoverflyClient = hoverflyClient ?? new HoverflyClient(
                new Uri($"{_hoverflyConfig.RemoteHost}:{_hoverflyConfig.AdminPort}"),
                _logger);
        }
 /// <summary>
 /// Changes the hoverfly mode.
 /// </summary>
 /// <param name="mode">The <see cref="HoverflyMode"/> to change to.</param>
 public void SetMode(HoverflyMode mode)
 {
     SetMode(new ModeCommand(mode));
 }
Esempio n. 7
0
 /// <summary>
 /// Changes the hoverfly mode.
 /// </summary>
 /// <param name="mode">The <see cref="HoverflyMode"/> to change to.</param>
 public void ChangeMode(HoverflyMode mode)
 {
     LogInfo($"Changing mode to '{mode}'");
     _hoverflyClient.SetMode(mode);
 }
Esempio n. 8
0
 /// <summary>
 /// Changes the hoverfly mode.
 /// </summary>
 /// <param name="mode">The <see cref="HoverflyMode"/> to change to.</param>
 public void ChangeMode(HoverflyMode mode)
 {
     _logger?.Info($"Changing mode to '{mode}'");
     _hoverflyClient.ChangeMode(mode);
 }
Esempio n. 9
0
 public ModeCommand(HoverflyMode mode, ModeArguments arguments)
 {
     Mode      = mode;
     Arguments = arguments;
 }
Esempio n. 10
0
 public ModeCommand(HoverflyMode mode)
 {
     Mode = mode;
 }