Exemplo n.º 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);
        }
Exemplo n.º 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"]);
        }
Exemplo n.º 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"]);
        }
Exemplo n.º 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"]);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        public void ShouldParseMultipleEndpoints()
        {
            var endpoints = YamlParser.FromFile("../../YAML/multiple.yaml");

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

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

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

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

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

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

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

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