Esempio n. 1
0
        public void UnnamedParameterCannotBeConvertedWithNamedMode()
        {
            var parameter = new BigqueryParameter(BigqueryParameterType.String, "foo");

            // Prove that it's fine for a positional parameter
            parameter.ToQueryParameter(BigqueryParameterMode.Positional);
            Assert.Throws <InvalidOperationException>(() => parameter.ToQueryParameter(BigqueryParameterMode.Named));
        }
Esempio n. 2
0
        public void ExplicitlyTypedArrayType()
        {
            var parameter = new BigqueryParameter(BigqueryParameterType.Array, new[] { new DateTimeOffset(new DateTime(2016, 10, 31), new TimeSpan(8, 30, 0)) });

            parameter.ArrayType = BigqueryParameterType.DateTime;
            string actualJson = JsonConvert.SerializeObject(parameter.ToQueryParameter(BigqueryParameterMode.Positional));

            var expectedResult = new QueryParameter
            {
                ParameterType = new QueryParameterType
                {
                    Type      = EnumMap.ToApiValue(BigqueryParameterType.Array),
                    ArrayType = new QueryParameterType {
                        Type = EnumMap.ToApiValue(BigqueryParameterType.DateTime)
                    }
                },
                ParameterValue = new QueryParameterValue
                {
                    ArrayValues = new[] { new QueryParameterValue {
                                              Value = "2016-10-31 00:00:00"
                                          } }
                }
            };
            string expectedJson = JsonConvert.SerializeObject(expectedResult);

            Assert.Equal(actualJson, expectedJson);
        }
Esempio n. 3
0
        public void ToQueryParameter_Valid(string name, BigqueryParameter parameter, QueryParameter expectedResult)
        {
            // Positional vs named mode difference is only in validation, tested elsewhere.
            string actualJson   = JsonConvert.SerializeObject(parameter.ToQueryParameter(BigqueryParameterMode.Positional));
            string expectedJson = JsonConvert.SerializeObject(expectedResult);

            Assert.Equal(actualJson, expectedJson);
        }
Esempio n. 4
0
        public void TypeInference(string name, object value, BigqueryParameterType expectedType)
        {
            var parameter = new BigqueryParameter();

            parameter.Value = value;
            var queryParameter = parameter.ToQueryParameter(BigqueryParameterMode.Positional);
            var actualType     = EnumMap <BigqueryParameterType> .ToValue(queryParameter.ParameterType.Type);

            Assert.Equal(expectedType, actualType);
        }
Esempio n. 5
0
        public void StructParametersNotImplemented()
        {
            var parameter = new BigqueryParameter(BigqueryParameterType.Struct, null);

            Assert.Throws <NotImplementedException>(() => parameter.ToQueryParameter(BigqueryParameterMode.Positional));
        }
Esempio n. 6
0
        public void ToQueryParameter_Invalid(string name, BigqueryParameterType?type, object value)
        {
            var parameter = new BigqueryParameter(type, value);

            Assert.Throws <InvalidOperationException>(() => parameter.ToQueryParameter(BigqueryParameterMode.Positional));
        }