Ejemplo n.º 1
0
        public void given_different_existing_query_params_when_adding_query_should_add_query_params()
        {
            var uri          = new Uri("http://www.microsoft.com?Id=1");
            var uriWithQuery = uri.With(DynamicDictionary.FromObject(new { FirstName = "Todd", Age = 42 }));

            uriWithQuery.Query.Should().Contain(string.Format("&FirstName={0}", "Todd"));
            uriWithQuery.Query.Should().Contain(string.Format("&Age={0}", 42));
        }
Ejemplo n.º 2
0
        public void given_same_existing_query_params_when_adding_query_should_replace_query_params()
        {
            var uri          = new Uri("http://www.microsoft.com?FirstName=Ellie&Age=14");
            var uriWithQuery =
                uri.With(DynamicDictionary.FromObject(new { FirstName = "Todd", BirthDate = 23.November(1972) }));

            uriWithQuery.Query.Should().Contain(string.Format("&FirstName={0}", "Todd"));
            uriWithQuery.Query.Should().Contain(Uri.EscapeUriString(string.Format("&BirthDate={0}", 23.November(1972))));
        }
Ejemplo n.º 3
0
        private void AssertQueryContainsValue(object query, string because = "", params object[] values)
        {
            var uri = new Uri("http://www.microsoft.com");

            var uriWithQuery = uri.With(DynamicDictionary.FromObject(query));

            foreach (var value in values)
            {
                uriWithQuery.Query.Should().Contain(Uri.EscapeUriString(string.Format("Value={0}", value)), because);
            }
        }