예제 #1
0
        public void TestStopRecordingSimple()
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();
            var targetFile  = "recordings/TestStartRecordSimple.json";

            httpContext.Request.Headers["x-recording-file"] = targetFile;

            var controller = new Record(testRecordingHandler)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };

            controller.Start();
            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();

            httpContext.Request.Headers["x-recording-id"] = recordingId;
            httpContext.Request.Headers.Remove("x-recording-file");

            controller.Stop();

            var fullPath = testRecordingHandler.GetRecordingPath(targetFile);

            Assert.True(File.Exists(fullPath));
        }
예제 #2
0
        public async Task TestStopRecordingSimple(string targetFile)
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();
            var body        = "{\"x-recording-file\":\"" + targetFile + "\"}";

            httpContext.Request.Body          = TestHelpers.GenerateStreamRequestBody(body);
            httpContext.Request.ContentLength = body.Length;

            var controller = new Record(testRecordingHandler)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };
            await controller.Start();

            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();

            httpContext.Request.Headers["x-recording-id"] = recordingId;
            httpContext.Request.Headers.Remove("x-recording-file");

            controller.Stop();

            var fullPath = testRecordingHandler.GetRecordingPath(targetFile);

            Assert.True(File.Exists(fullPath));
        }
예제 #3
0
        public async Task TestStopRecordingSimple(string targetFile, string additionalEntryModeHeader)
        {
            RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
            var httpContext = new DefaultHttpContext();
            var body        = "{\"x-recording-file\":\"" + targetFile + "\"}";

            httpContext.Request.Body          = TestHelpers.GenerateStreamRequestBody(body);
            httpContext.Request.ContentLength = body.Length;
            var controller = new Record(testRecordingHandler, _nullLogger)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };
            await controller.Start();

            var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();

            httpContext.Request.Headers["x-recording-id"] = recordingId;
            httpContext.Request.Headers.Remove("x-recording-file");

            if (!string.IsNullOrEmpty(additionalEntryModeHeader))
            {
                httpContext.Request.Headers["x-recording-skip"] = additionalEntryModeHeader;
            }

            controller.Stop();

            if (string.IsNullOrEmpty(additionalEntryModeHeader))
            {
                var fullPath = testRecordingHandler.GetRecordingPath(targetFile);
                Assert.True(File.Exists(fullPath));
            }
            else
            {
                var fullPath = testRecordingHandler.GetRecordingPath(targetFile);
                Assert.False(File.Exists(fullPath));
            }
        }