Пример #1
0
        public void ScriptCanLoadAnotherScript()
        {
            var drc  = new FileDynamicResponseCreator(Path.Combine(dc.DirectoryName, "a\\main.csscript"));
            var body = drc.GetBody(new RequestInfo());

            Assert.Equal("foo", body);
        }
Пример #2
0
        public void CanUseParamForDelay()
        {
            var responseCreator = new FileDynamicResponseCreator("file.txt", endpoint);

            responseCreator.SetDelayFromConfigValue("$delay");

            Assert.Equal(0, responseCreator.Delay);
            delayParam.Value = "1000";
            Assert.Equal(1000, responseCreator.Delay);
        }
Пример #3
0
        public async Task ScriptCanLoadAnotherScript()
        {
            var drc = new FileDynamicResponseCreator("a/main.csscript", new Endpoint("a", "b")
            {
                Directory = dc.DirectoryName
            });
            var body = await drc.GetBodyAsync(new RequestInfo());

            Assert.Equal("foo", body);
        }
Пример #4
0
        public async Task CanUseParamForScriptFilename()
        {
            dc.AddFile("file.txt", "return \"I am file.txt: \" + GetParam(\"filename\");");
            dc.AddFile("another.txt", "return \"I am another.txt: \" + GetParam(\"filename\");");

            var responseCreator = new FileDynamicResponseCreator("$filename", endpoint);

            Assert.Equal(Path.Combine(endpoint.Directory, "file.txt"), responseCreator.Filename);
            Assert.Equal("I am file.txt: file.txt", (await GetResponseAsync(responseCreator)).WrittenContent);

            filenameParam.Value = "another.txt";
            Assert.Equal(Path.Combine(endpoint.Directory, "another.txt"), responseCreator.Filename);
            Assert.Equal("I am another.txt: another.txt", (await GetResponseAsync(responseCreator)).WrittenContent);
        }