Exemplo n.º 1
0
        public void RepeatableEnum_SinglePropertySet()
        {
            var request = new RepeatableEnumRequest {
                Mode = FileMode.Open
            };
            var dictionary = ParameterUtils.CreateParameterDictionary(request);

            Assert.Equal(FileMode.Open, dictionary["mode"]);
        }
Exemplo n.º 2
0
        public void RepeatableEnum_BothPropertiesSet()
        {
            var request = new RepeatableEnumRequest
            {
                Mode     = FileMode.Open,
                ModeList = new[] { FileMode.Create, FileMode.Append }
            };

            Assert.Throws <InvalidOperationException>(() => ParameterUtils.CreateParameterDictionary(request));
        }
Exemplo n.º 3
0
        public void RepeatableEnum_NoPropertiesSet()
        {
            var request    = new RepeatableEnumRequest();
            var dictionary = ParameterUtils.CreateParameterDictionary(request);
            // For historical reasons, we end up with a null value from the "FileMode? Mode" property.
            // That's fixable, but not worth the worry about whether it would break things.
            var pair = Assert.Single(dictionary);

            Assert.Equal("mode", pair.Key);
            Assert.Null(pair.Value);
        }
Exemplo n.º 4
0
        public void RepeatableEnum_ListPropertySet()
        {
            var request = new RepeatableEnumRequest {
                ModeList = new[] { FileMode.Open, FileMode.Append }
            };
            var dictionary = ParameterUtils.CreateParameterDictionary(request);
            var pair       = Assert.Single(dictionary);

            Assert.Equal("mode", pair.Key);
            var repeatable = (Repeatable <FileMode>)pair.Value;

            Assert.Equal(new[] { FileMode.Open, FileMode.Append }, repeatable.ToArray());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the <see cref="Google.Apis.Requests.RequestBuilder"/> which is used to generate a request.
        /// </summary>
        /// <returns>
        /// A new builder instance which contains the HTTP method and the right Uri with its path and query parameters.
        /// </returns>
        private RequestBuilder CreateBuilder()
        {
            var builder = new RequestBuilder()
            {
                BaseUri = new Uri(Service.BaseUri),
                Path    = RestPath,
                Method  = HttpMethod,
            };

            // Init parameters.
            builder.AddParameter(RequestParameterType.Query, "key", service.ApiKey);
            var parameters = ParameterUtils.CreateParameterDictionary(this);

            AddParameters(builder, ParameterCollection.FromDictionary(parameters));
            return(builder);
        }