public async Task <KvObject <T> > GetAsync <T>(string key, string versionReference = null)
        {
            Guard.ArgumentNotNullOrEmpty("key", key);

            HttpUrlBuilder uri = new HttpUrlBuilder(host)
                                 .AppendPath(CollectionName)
                                 .AppendPath(key);

            if (versionReference != null)
            {
                uri.AppendPath("refs")
                .AppendPath(versionReference);
            }

            var response = await restClient.GetAsync(uri);

            return(new KvObject <T>(response.Content, CollectionName, key, response.ETag, response.Location, serializer));
        }
        public async Task <EventMetaData> AddEventAsync <T>(string key, string eventType, T @event, DateTimeOffset?timestamp = null)
        {
            Guard.ArgumentNotNullOrEmpty(nameof(key), key);
            Guard.ArgumentNotNullOrEmpty(nameof(eventType), eventType);
            Guard.ArgumentNotNull(nameof(@event), @event);

            HttpUrlBuilder uri = new HttpUrlBuilder(host)
                                 .AppendPath(CollectionName)
                                 .AppendPath(key)
                                 .AppendPath("events")
                                 .AppendPath(eventType);

            if (timestamp.HasValue)
            {
                uri.AppendPath(UnixTime.FromDateTimeOffset(timestamp.Value).ToString());
            }

            var response = await restClient.SendAsync(uri, HttpMethod.Post, @event);

            return(EventMetaData.Make(response));
        }
        public void FormatsPath()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendPath("foo/{0}", "bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void DoesNotEncodeThePathSeperator()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendPath("foo/bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void EncodesPathArguments()
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendPath("foo/{0}", "bar#bar");

            Assert.Equal("/foo/bar%23bar", builder.ToUri().AbsolutePath);
        }
        public void EncodesPath(string path, string expectedPath)
        {
            var builder = new HttpUrlBuilder("http://localhost");

            builder.AppendPath(path);

            Assert.Equal(expectedPath, builder.ToUri().AbsolutePath);
        }
        public void WhenNoExistingPath_SetsAbsolutePath(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendPath("foo/bar");

            Assert.Equal("/foo/bar", builder.ToUri().AbsolutePath);
        }
        public void AppendsPathToExisting(string url)
        {
            var builder = new HttpUrlBuilder(url);

            builder.AppendPath("foo/bar");

            Assert.Equal("/existing/path/foo/bar", builder.ToUri().AbsolutePath);
        }