예제 #1
0
        public void ShouldParseResponse_WithFile()
        {
            const string file     = "../../YAML/response-file.yaml";
            var          endpoint = YamlParser.FromFile(file)[0];

            Assert.AreEqual(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(file), "path/to/response/body")), endpoint.Responses[0].File);
        }
예제 #2
0
        public void ShouldParseResponse_WithHeaders()
        {
            var endpoint = YamlParser.FromFile("../../YAML/response-headers.yaml")[0];

            Assert.AreEqual("application/json", endpoint.Responses[0].Headers["content-type"]);
            Assert.AreEqual("application/json", endpoint.Responses[0].Headers["accept"]);
        }
예제 #3
0
        public void ShouldParseRequest_WithQuery()
        {
            var endpoint = YamlParser.FromFile("../../YAML/request-query.yaml")[0];

            Assert.AreEqual("tada", endpoint.Request.Query["first"]);
            Assert.AreEqual("voila", endpoint.Request.Query["second"]);
        }
예제 #4
0
        public void ShouldParseRequest_WithHeaders()
        {
            var endpoint = YamlParser.FromFile("../../YAML/request-headers.yaml")[0];

            Assert.AreEqual("text/xml", endpoint.Request.Headers["content-type"]);
            Assert.AreEqual("firefox(Mozilla)", endpoint.Request.Headers["user-agent"]);
        }
예제 #5
0
        private void LoadEndpoints()
        {
            IList <Endpoint> endpoints = new List <Endpoint>();

            try
            {
                endpoints = YamlParser.FromFile(_arguments.Data);
            }
            catch (FileNotFoundException)
            {
                Out.Warn("File '" + _arguments.Data + "' couldn't be found. Ignoring...");
            }
            catch (YamlException ex)
            {
                Out.Error(ex.Message);
                throw new EndpointParsingException("Could not parse endpoints due to YAML errors.", ex);
            }

            _endpointDb.Delete();
            _endpointDb.Insert(endpoints);
        }
예제 #6
0
        public void ShouldParseMultipleEndpoints()
        {
            var endpoints = YamlParser.FromFile("../../YAML/multiple.yaml");

            Assert.AreEqual(3, endpoints.Count);
        }
예제 #7
0
        public void ShouldParseResponse_WithBody()
        {
            var endpoint = YamlParser.FromFile("../../YAML/response-body.yaml")[0];

            Assert.AreEqual("body contents!", endpoint.Responses[0].Body);
        }
예제 #8
0
        public void ShouldParseRequest_WithUrl()
        {
            var endpoint = YamlParser.FromFile("../../YAML/hello-world.yaml")[0];

            Assert.AreEqual("/hello/world", endpoint.Request.Url);
        }
예제 #9
0
        public void ShouldParseRequest_WithPostBody()
        {
            var endpoint = YamlParser.FromFile("../../YAML/request-post.yaml")[0];

            Assert.AreEqual("post body!", endpoint.Request.Post);
        }
예제 #10
0
        public void ShouldParseRequest_WithManyMethods()
        {
            var endpoint = YamlParser.FromFile("../../YAML/request-methods.yaml")[0];

            Assert.AreEqual(new[] { "GET", "HEAD" }, endpoint.Request.Method);
        }
예제 #11
0
        public void ShouldParseRequest_WithMethod()
        {
            var endpoint = YamlParser.FromFile("../../YAML/request-method.yaml")[0];

            Assert.AreEqual(new[] { "DELETE" }, endpoint.Request.Method);
        }
예제 #12
0
 public void ShouldReturnEmptyArray_GivenNullOrWhitespaceFileName()
 {
     Assert.IsEmpty(YamlParser.FromFile(""));
     Assert.IsEmpty(YamlParser.FromFile(null));
 }
예제 #13
0
        public void ShouldParseResponse_WithStatus()
        {
            var endpoint = YamlParser.FromFile("../../YAML/response-status.yaml")[0];

            Assert.AreEqual(204, endpoint.Responses[0].Status);
        }
예제 #14
0
        public void ShouldParseResponse_WithLatency()
        {
            var endpoint = YamlParser.FromFile("../../YAML/response-latency.yaml")[0];

            Assert.AreEqual(987654321, endpoint.Responses[0].Latency);
        }