public void Assign_New_Uri_To_Existing_Test()
        {
            var uri = new UriFormatter("http://m6400/sdata/-/-/-/");
            var expected = new[] {new UriPathSegment("-"), new UriPathSegment("-"), new UriPathSegment("-")};
            CollectionAssert.AreEquivalent(uri.PathSegments, expected);

            uri.Uri = new Uri("http://localhost:3333/sdata/aw/dynamic/-/");
            expected = new[] {new UriPathSegment("aw"), new UriPathSegment("dynamic"), new UriPathSegment("-")};
            CollectionAssert.AreEquivalent(uri.PathSegments, expected);
        }
        public void Support_Uri_Fragments_Test()
        {
            var uri = new UriFormatter("http://m6400/sdata/-/-/-/#one");
            Assert.That(uri.Fragment, Is.EqualTo("one"));

            uri.Host = "localhost";
            Assert.That(uri.Fragment, Is.EqualTo("one"));

            uri.Fragment = "two";
            StringAssert.EndsWith("#two", uri.ToString());
        }
        public void Modifying_QueryArgs_Should_Update_Query_And_ToString_Test()
        {
            var uri = new UriFormatter("http://localhost");

            Assert.That(string.IsNullOrEmpty(uri.Query));
            Assert.That(uri.QueryArgs.Count == 0);
            Assert.That(uri.ToString() == "http://localhost/");

            uri.QueryArgs.Add("orderBy", "name");

            Assert.That(uri.Query == "orderBy=name");
            Assert.That(uri.QueryArgs.Count == 1);
            Assert.That(uri.ToString() == "http://localhost/?orderBy=name");

            uri.QueryArgs.Clear();

            Assert.That(string.IsNullOrEmpty(uri.Query));
            Assert.That(uri.QueryArgs.Count == 0);
            Assert.That(uri.ToString() == "http://localhost/");
        }
Пример #4
0
        /// <summary>
        /// Initialises a new instance of the <see cref="UriFormatter"/> class with
        /// the specified <see cref="Uri"/>.
        /// </summary>
        /// <param name="uri">The <see cref="Uri"/> to assign.</param>
        public UriFormatter(UriFormatter uri)
        {
            _uri = uri._uri;
            _requiresParseUri   = uri._requiresParseUri;
            _requiresRebuildUri = uri._requiresRebuildUri;
            _scheme             = uri._scheme;
            _port       = uri._port;
            _host       = uri._host;
            _pathPrefix = uri._pathPrefix;
            _server     = uri._server;
            _fragment   = uri._fragment;

            PathInternal         = uri.PathInternal;
            _directPath          = uri._directPath;
            _requiresParsePath   = uri._requiresParsePath;
            _requiresRebuildPath = uri._requiresRebuildPath;

            if (uri._pathSegments != null)
            {
                _pathSegments = new List <UriPathSegment>(uri._pathSegments.Count);

                foreach (var segment in uri._pathSegments)
                {
                    var clone = new UriPathSegment(segment)
                    {
                        Formatter = this
                    };
                    _pathSegments.Add(clone);
                }
            }

            if (uri._queryArgs != null)
            {
                _queryArgs = new QueryArgsDictionary(this, uri._queryArgs);
            }
        }
Пример #5
0
 /// <summary>
 /// Initialises a new instance of the <see cref="SDataUri"/> class with
 /// the specified <see cref="Uri"/>.
 /// </summary>
 /// <param name="uri">The <see cref="Uri"/> to assign.</param>
 public SDataUri(UriFormatter uri)
     : base(uri)
 {
 }
Пример #6
0
 /// <summary>
 /// Initialises a new instance of the <see cref="SDataUri"/> class with
 /// the specified <see cref="Uri"/>.
 /// </summary>
 /// <param name="uri">The <see cref="Uri"/> to assign.</param>
 public SDataUri(UriFormatter uri)
     : base(uri)
 {
 }
Пример #7
0
 public QueryArgsDictionary(UriFormatter uri, IDictionary <string, string> items)
     : base(items, StringComparer.InvariantCultureIgnoreCase)
 {
     _uri = uri;
 }
Пример #8
0
 public QueryArgsDictionary(UriFormatter uri, string query)
     : this(uri, Parse(query))
 {
 }
Пример #9
0
 public QueryArgsDictionary(UriFormatter uri)
     : base(StringComparer.InvariantCultureIgnoreCase)
 {
     _uri = uri;
 }
        /// <summary>
        /// Initialises a new instance of the <see cref="UriFormatter"/> class with
        /// the specified <see cref="Uri"/>.
        /// </summary>
        /// <param name="uri">The <see cref="Uri"/> to assign.</param>
        public UriFormatter(UriFormatter uri)
        {
            _uri = uri._uri;
            _requiresParseUri = uri._requiresParseUri;
            _requiresRebuildUri = uri._requiresRebuildUri;
            _scheme = uri._scheme;
            _port = uri._port;
            _host = uri._host;
            _pathPrefix = uri._pathPrefix;
            _server = uri._server;
            _fragment = uri._fragment;

            PathInternal = uri.PathInternal;
            _directPath = uri._directPath;
            _requiresParsePath = uri._requiresParsePath;
            _requiresRebuildPath = uri._requiresRebuildPath;

            if (uri._pathSegments != null)
            {
                _pathSegments = new List<UriPathSegment>(uri._pathSegments.Count);

                foreach (var segment in uri._pathSegments)
                {
                    var clone = new UriPathSegment(segment) {Formatter = this};
                    _pathSegments.Add(clone);
                }
            }

            if (uri._queryArgs != null)
                _queryArgs = new Dictionary<string, string>(uri._queryArgs, StringComparer.InvariantCultureIgnoreCase);
        }