public void ShouldStartInSimulationMode() { using (var runner = HoverflyRunner.StartInSimulationMode()) { Assert.Equal(HoverflyMode.Simulate, runner.GetHoverflyMode()); } }
public void ShouldStartInSimulationMode() { using (var runner = HoverflyRunner.StartInSimulationMode(HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { Assert.Equal(HoverflyMode.Simulate, runner.GetHoverflyMode()); } }
public void ShouldExportSimulationOnStop_WhenInCaptureMode() { var fakeDestination = new FakeSimulationDestinationSource(); var runner = HoverflyRunner.StartInCaptureMode(fakeDestination); runner.Dispose(); Assert.Equal(true, fakeDestination.WasSaved); }
public void ShouldStartInCaptureMode() { var fakeDestination = new FakeSimulationDestinationSource(); using (var runner = HoverflyRunner.StartInCaptureMode(fakeDestination)) { Assert.Equal(HoverflyMode.Capture, runner.GetHoverflyMode()); } }
public void ShouldLoadSimulation_WhenStartInSimulationModeWithASimulationSourceAsFile() { using (var runner = HoverflyRunner.StartInSimulationMode("simulation_test.json")) { var simulation = runner.GetSimulation(); Assert.Equal("echo.jsontest.com", simulation.HoverflyData.RequestResponsePair.First().Request.Destination); Assert.Equal(HoverflyMode.Simulate, runner.GetHoverflyMode()); } }
public void ShouldStartInCaptureMode() { var fakeDestination = new FakeSimulationDestinationSource(); using (var runner = HoverflyRunner.StartInCaptureMode(fakeDestination, HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { Assert.Equal(HoverflyMode.Capture, runner.GetHoverflyMode()); } }
public void ShouldGetExternalResponse_WhenUsingSpyModeAndSimulationIsNotAdded() { using (var runner = HoverflyRunner.StartInSpyMode(HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { var result = GetContentFrom("http://echo.jsontest.com/key/value/one/two?name=testSpy"); Assert.Equal("{\n \"one\": \"two\",\n \"key\": \"value\"\n}\n", result); } }
public void ShouldGetSimulationResponse_WhenUsingSpyModeAndSimulationFromFileIsAreadyAdded() { using (var runner = HoverflyRunner.StartInSpyMode("simulation_test.json", HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { var result = GetContentFrom("http://echo.jsontest.com/key/value/one/two"); Assert.Equal("{\n \"one\": \"two\",\n \"key\": \"value\"\n}\n", result); } }
public void ShouldExportSimulationOnStop_WhenInCaptureMode() { var fakeDestination = new FakeSimulationDestinationSource(); using (var runner = HoverflyRunner.StartInCaptureMode(fakeDestination, HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { } Assert.Equal(true, fakeDestination.WasSaved); }
public void ShouldLoadSimulation_WhenStartInSimulationModeWithASimulationSource() { var fakeSource = new FileSimulationSource("simulation_test.json"); using (var runner = HoverflyRunner.StartInSimulationMode(fakeSource, HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { var simulation = runner.GetSimulation(); Assert.Equal("echo.jsontest.com", simulation.HoverflyData.RequestResponsePair.First().Request.Destination.ExactMatch); Assert.Equal(HoverflyMode.Simulate, runner.GetHoverflyMode()); } }
public void ShouldReturnCorrectSimulation_WhenUsingSimulateWithDsl() { using (var runner = HoverflyRunner.StartInSimulationMode()) { runner.Simulate(DslSimulationSource.Dsl( Service("http://echo.jsontest.com") .Get("/key/value/three/four") .QueryParam("name", "test") .WillReturn( Success("Hello World!", "application/json")))); var result = GetContentFrom("http://echo.jsontest.com/key/value/three/four?name=test"); Assert.Equal("Hello World!", result); } }
public void ShouldGetSimulationResponse_WhenUsingSpyModeAndSimulationDslIsAreadyAddedDuringStart() { var simulation = DslSimulationSource.Dsl( Service("http://echo.jsontest.com") .Get("/key/value/three/four") .QueryParam("name", "test") .WillReturn( Success("MyData", "application/json"))); using (var runner = HoverflyRunner.StartInSpyMode(simulation, HoverFlyTestConfig.GetHoverFlyConfigWIthBasePath())) { var result = GetContentFrom("http://echo.jsontest.com/key/value/three/four?name=test"); Assert.Equal("MyData", result); } }
public void ShouldReturnCorrectSimulations_WhenUsingAnExistingSimulateAndWhenAddingOne() { using (var runner = HoverflyRunner.StartInSimulationMode("simulation_test.json")) { runner.AddSimulation(DslSimulationSource.Dsl( Service("http://echo.jsontest.com") .Get("/key/value/six/seven") .QueryParam("name", "test") .WillReturn( Success("Hello World!", "application/json")))); var simulation = runner.GetSimulation(); Assert.Equal("echo.jsontest.com", simulation.HoverflyData.RequestResponsePair.First().Request.Destination); Assert.Equal("/key/value/one/two", simulation.HoverflyData.RequestResponsePair.First().Request.Path); Assert.Equal("echo.jsontest.com", simulation.HoverflyData.RequestResponsePair.Last().Request.Destination); Assert.Equal("/key/value/six/seven", simulation.HoverflyData.RequestResponsePair.Last().Request.Path); } }