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)); }
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); }
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); }
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); }
public void StructParametersNotImplemented() { var parameter = new BigqueryParameter(BigqueryParameterType.Struct, null); Assert.Throws <NotImplementedException>(() => parameter.ToQueryParameter(BigqueryParameterMode.Positional)); }
public void ToQueryParameter_Invalid(string name, BigqueryParameterType?type, object value) { var parameter = new BigqueryParameter(type, value); Assert.Throws <InvalidOperationException>(() => parameter.ToQueryParameter(BigqueryParameterMode.Positional)); }