public void BuildParameters_BytesArray(byte[] value, string expectedString, string bindingType) { var binding = ParameterBinder.BuildParameterBindings(value); Assert.AreEqual(1, binding.Count); Assert.IsTrue(binding.ContainsKey("1")); Assert.AreEqual(bindingType, binding["1"].Type); Assert.AreEqual(expectedString, binding["1"].Value); }
public void BuildParameters_String(string value, string bindingType) { var binding = ParameterBinder.BuildParameterBindings(value); Assert.AreEqual(1, binding.Count); Assert.IsTrue(binding.ContainsKey("1")); Assert.AreEqual(bindingType, binding["1"].Type); Assert.AreEqual(value, binding["1"].Value); }
public void BuildParameters_DateTime(string stringValue, string expectedString, string bindingType) { var value = DateTime.ParseExact(stringValue, "yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.InvariantCulture); var binding = ParameterBinder.BuildParameterBindings(value); Assert.AreEqual(1, binding.Count); Assert.IsTrue(binding.ContainsKey("1")); Assert.AreEqual(bindingType, binding["1"].Type); Assert.AreEqual(expectedString, binding["1"].Value); }
public void BuildParameters_Guid() { var guid = Guid.NewGuid(); var binding = ParameterBinder.BuildParameterBindings(guid); var stringValue = string.Format(CultureInfo.InvariantCulture, "{0}", guid); Assert.AreEqual(1, binding.Count); Assert.IsTrue(binding.ContainsKey("1")); Assert.AreEqual("TEXT", binding["1"].Type); Assert.AreEqual(stringValue, binding["1"].Value); }
public void BuildParameters_Numeric(object objectValue, Type type, string bindingType) { var value = Convert.ChangeType(objectValue, type); var binding = ParameterBinder.BuildParameterBindings(value); Assert.AreEqual(1, binding.Count); Assert.IsTrue(binding.ContainsKey("1")); Assert.AreEqual(bindingType, binding["1"].Type); var stringValue = string.Format(CultureInfo.InvariantCulture, "{0}", objectValue); Assert.AreEqual(stringValue, binding["1"].Value); }
public void BuildParameters_FromAnonymousType() { var value = new { IntProperty = 2, StringProperty = "test" }; var bindings = ParameterBinder.BuildParameterBindings(value); Assert.IsTrue(bindings.ContainsKey(nameof(value.IntProperty))); Assert.IsTrue(bindings[nameof(value.IntProperty)].Type == "FIXED"); Assert.IsTrue(bindings[nameof(value.IntProperty)].Value == value.IntProperty.ToString()); Assert.IsTrue(bindings.ContainsKey(nameof(value.StringProperty))); Assert.IsTrue(bindings[nameof(value.StringProperty)].Type == "TEXT"); Assert.IsTrue(bindings[nameof(value.StringProperty)].Value == value.StringProperty); }
public void BuildParameters_FromStruct_Fields() { var value = new CustomStructWithFields() { IntField = 2, StringField = "test" }; var bindings = ParameterBinder.BuildParameterBindings(value); Assert.IsTrue(bindings.ContainsKey(nameof(value.IntField))); Assert.IsTrue(bindings[nameof(value.IntField)].Type == "FIXED"); Assert.IsTrue(bindings[nameof(value.IntField)].Value == value.IntField.ToString()); Assert.IsTrue(bindings.ContainsKey(nameof(value.StringField))); Assert.IsTrue(bindings[nameof(value.StringField)].Type == "TEXT"); Assert.IsTrue(bindings[nameof(value.StringField)].Value == value.StringField); }
public void BuildParameters_Array() { var values = GetStringValues().ToArray(); var bindings = ParameterBinder.BuildParameterBindings(values); Assert.AreEqual(values.Length, bindings.Count); int i = 1; foreach (var binding in bindings) { Assert.IsTrue(binding.Key == i.ToString()); Assert.IsTrue(binding.Value.Type == "TEXT"); Assert.IsTrue(binding.Value.Value == values[i - 1]); i++; } }
public void BuildParameters_Enumerable() { var values = GetStringValues(); var valuesList = values.ToList(); var bindings = ParameterBinder.BuildParameterBindings(values); Assert.AreEqual(values.Count(), bindings.Count); int i = 1; foreach (var binding in bindings) { Assert.IsTrue(binding.Key == i.ToString()); Assert.IsTrue(binding.Value.Type == "TEXT"); Assert.IsTrue(binding.Value.Value == valuesList[i - 1]); i++; } }
public void BuildParameters_IEnumerableOfComplexTypes() { var values = GetCustomClassCollection(); Assert.Throws <ArgumentException>(() => ParameterBinder.BuildParameterBindings(values)); }