public void RequestDataWithCollection()
        {
            var queryStringBuilder = new RequestDataBuilder();

            queryStringBuilder.AppendItem("ArrayOfThings", 1);
            queryStringBuilder.AppendItem("ArrayOfThings", 2);
            queryStringBuilder.AppendItem("ArrayOfThings", 3);
            queryStringBuilder.AppendItem("SingleThing", "hi");

            var serializer = mockup.Get <JsonSerializer>();

            using (var stream = new MemoryStream())
            {
                using (var writer = new JsonTextWriter(new StreamWriter(stream, Encoding.Default, 4096, true)))
                {
                    serializer.Serialize(writer, queryStringBuilder.Data);
                }

                stream.Seek(0, SeekOrigin.Begin);

                using (var reader = new StreamReader(stream))
                {
                    var json     = reader.ReadToEnd();
                    var filename = $"{nameof(RequestDataWithCollection)}.json";
                    FileUtils.WriteTestFile(this.GetType(), filename, json);
                    var expected = FileUtils.ReadTestFile(this.GetType(), filename);
                    Assert.Equal(expected, json);
                }
            }
        }
Esempio n. 2
0
        protected override void AddCustomQuery(string rel, RequestDataBuilder queryString)
        {
            if (query.File != null)
            {
                queryString.AppendItem("file", query.File);
            }

            if (ShowChangedOnly)
            {
                queryString.AppendItem("showChangedOnly", query.ShowChangedOnly.ToString());
            }

            base.AddCustomQuery(rel, queryString);
        }
Esempio n. 3
0
 public void AddQuery(string rel, RequestDataBuilder queryString)
 {
     if (File != null && rel == HalSelfActionLinkAttribute.SelfRelName)
     {
         queryString.AppendItem("file", File);
     }
 }
Esempio n. 4
0
        protected override void AddCustomQuery(string rel, RequestDataBuilder queryString)
        {
            if (query.File != null)
            {
                queryString.AppendItem("file", query.File.TrimStartingPathChars());
            }

            base.AddCustomQuery(rel, queryString);
        }