예제 #1
0
        public void Responses()
        {
            var endpoint  = JSONReader.ReadEndpoint(ENDPOINTJSON, "p:\\ath\\to\\endpoint\\directory", globalDefaults: null);
            var responses = endpoint.Responses.ToArray();

            Assert.Equal(2, responses.Length);

            var rm0 = responses[0].Item1 as RegexMatcher;
            var rc0 = responses[0].Item2 as FileResponse;

            Assert.NotNull(rm0);
            Assert.NotNull(rc0);

            Assert.Equal("p:\\ath\\to\\endpoint\\directory\\content.txt", rc0.Filename);
            Assert.Equal("text/plain", rc0.ContentType);
            Assert.Equal(10, rc0.Delay);
            Assert.Equal(0, rc0.Replacements.Length);

            var rm1 = responses[1].Item1 as AnyMatcher;
            var rc1 = responses[1].Item2 as FileDynamicResponseCreator;

            Assert.NotNull(rm1);
            Assert.NotNull(rc1);
            Assert.Equal("p:\\ath\\to\\endpoint\\directory\\myscript.csscript", rc1.Filename);
            Assert.Equal("text/xml", rc1.ContentType);
            Assert.Equal(0, rc1.Delay);
            Assert.Equal(2, rc1.Replacements.Length);
        }
예제 #2
0
        public void SimpleEndpointAttributes()
        {
            var endpoint = JSONReader.ReadEndpoint(ENDPOINTJSON, "p:\\ath\\to\\endpoint\\directory", globalDefaults: null);

            Assert.Equal("foo", endpoint.Name);
            Assert.Equal("^/foo/$", endpoint.PathRegex);
        }
예제 #3
0
        private Tuple <RequestMatcher, ResponseCreator> ParseResponse(string json)
        {
            var endpoint  = JSONReader.ReadEndpoint("{'name': 'foo', 'pathregex': 'foo', 'responses': [" + json + "]}", "r:\\oot\\directory", globalDefaults: null);
            var responses = endpoint.Responses.ToArray();

            Debug.Assert(responses.Length == 1);
            return(responses[0]);
        }
예제 #4
0
        public void DoNotRecordRequestsAttribute()
        {
            var endpoint = JSONReader.ReadEndpoint("{'name': 'foo', 'pathregex': 'bar', 'responses': [], 'record': false}", "p:\\ath\\to\\endpoint\\directory", globalDefaults: null);

            Assert.False(endpoint.RecordRequests);
        }