public void Map_MapToObjectArray() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery_ObjectArray()); result.Length.Should().Be(3); result[0].Should().Be(5); result[1].Should().Be("TEST"); result[2].Should().Be(true); }
public void Map_ObjectWithStringArrayProperty() { var target = RunnerFactory.Create(); var result = target.Query <TestObjectStringArray>("SELECT 5 AS TestString, 'TEST' AS TestString, 3.14 AS TestString;").First(); result.TestString.Length.Should().Be(3); result.TestString[0].Should().Be("5"); result.TestString[1].Should().Be("TEST"); result.TestString[2].Should().Be("3.14"); }
public void Map_ArrayOfCustomObject() { var target = RunnerFactory.Create(); var result = target.Query(SqlQuery.FromString <TestObject1[]>("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;")).First(); result.Length.Should().Be(1); result[0].TestString.Should().Be("TEST"); result[0].TestInt.Should().Be(5); result[0].TestBool.Should().Be(true); }
public void Map_ObjectWithTupleProperty() { var target = RunnerFactory.Create(); var result = target.Query <TestObjectWithTuple>("SELECT 5 AS Id, 'TEST' AS Items, 6 AS Items, 3.14 AS Items").First(); result.Id.Should().Be(5); result.Items.Item1.Should().Be("TEST"); result.Items.Item2.Should().Be(6); result.Items.Item3.Should().Be(3.14f); }
public void Map_ListOfInt() { var target = RunnerFactory.Create(); var result = target.Query <List <int> >("SELECT 5, 6, '7'").First(); result.Count.Should().Be(3); result[0].Should().Be(5); result[1].Should().Be(6); result[2].Should().Be(7); }
public void Map_IList() { var target = RunnerFactory.Create(); var result = target.Query <IList>("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;").First(); result.Count.Should().Be(3); result[0].Should().Be(5); result[1].Should().Be("TEST"); result[2].Should().Be(true); }
public void TestQuery_MapToUnnamedValuesCollectionCtor() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery_UnnamedColumns <TestObjectUnnamedValuesCtor>()); result.UnnamedValues.Count.Should().Be(3); result.UnnamedValues[0].Should().Be("5"); result.UnnamedValues[1].Should().Be("TEST"); result.UnnamedValues[2].Should().Be("3.14"); }
public void TestQuery_IListOfCustomObject() { var target = RunnerFactory.Create(); var result = target.Query <IList <TestObject1> >("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;").First(); result.Count.Should().Be(1); result[0].TestString.Should().Be("TEST"); result[0].TestInt.Should().Be(5); result[0].TestBool.Should().Be(true); }
public void Map_ISetT() { var target = RunnerFactory.Create(); var result = target.Query <ISet <int> >("SELECT 5 AS A, 6 AS B, 7 AS C;").First(); result.Count.Should().Be(3); result.Contains(5).Should().BeTrue(); result.Contains(6).Should().BeTrue(); result.Contains(7).Should().BeTrue(); }
public void Map_DictionaryOfListOfInt() { var target = RunnerFactory.Create(); var dict = target.Query <Dictionary <string, List <int> > >("SELECT 1 AS A, 2 AS A, 3 AS B, 4 AS B, 5 AS C;").First(); dict.Count.Should().Be(3); dict["A"].Should().ContainInOrder(1, 2); dict["B"].Should().ContainInOrder(3, 4); dict["C"].Should().ContainInOrder(5); }
public void Map_StringArray() { var target = RunnerFactory.Create(); var result = target.Query(new StringArrayQuery()); result.Length.Should().Be(3); result[0].Should().Be("5"); result[1].Should().Be("TEST"); result[2].Should().Be("1"); }
public void Map_DictionaryOfObject() { var target = RunnerFactory.Create(); var result = target.Query <Dictionary <string, object> >("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;").First(); result.Count.Should().Be(3); result["TestString"].Should().Be("TEST"); result["TestInt"].Should().Be(5); result["TestBool"].Should().Be(true); }
public void Map_CustomObjectWithChildDictionary() { var target = RunnerFactory.Create(); var result = target.Query <TestObject_ChildDict>("SELECT 5 AS Id, 'TEST' AS Child_String, 6 AS Child_Int;").First(); result.Id.Should().Be(5); result.Child.Count.Should().Be(2); result.Child["String"].Should().Be("TEST"); result.Child["Int"].Should().Be("6"); }
public void FactoryMethod_ReturnsNull() { var target = RunnerFactory.Create(); Action func = () => { var result = target.Query(new FactoryMethodReturnsNullQuery()); }; func.Should().Throw <Exception>(); }
public void TestQuery_MapToStringArrayCtorParam() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery_StringList <TestObjectStringArrayCtor>()); result.TestString.Length.Should().Be(3); result.TestString[0].Should().Be("5"); result.TestString[1].Should().Be("TEST"); result.TestString[2].Should().Be("3.14"); }
public void Primitive_Guid_Nullable() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery <Guid?>("SELECT NEWID() AS TestId;")); result.Should().NotBe(Guid.Empty); result = target.Query(new TestQuery <Guid?>("SELECT NULL AS TestId;")); result.Should().BeNull(); }
public void Primitive_int_Nullable() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery <int?>("SELECT 5 AS TestInt;")); result.Should().Be(5); result = target.Query(new TestQuery <int?>("SELECT NULL AS TestInt;")); result.Should().BeNull(); }
public void Map_ObjectWithStringIListCtorParam() { var target = RunnerFactory.Create(); var result = target.Query(new StringListQuery <TestObjectStringIListCtor>()); result.TestString.Count.Should().Be(3); result.TestString[0].Should().Be("5"); result.TestString[1].Should().Be("TEST"); result.TestString[2].Should().Be("3.14"); }
public void Map_ObjectWithArrayOfStringCtorParameter() { var target = RunnerFactory.Create(); var result = target.Query(new Map_StringList <TestObjectStringArrayCtor>()); result.TestString.Length.Should().Be(3); result.TestString[0].Should().Be("5"); result.TestString[1].Should().Be("TEST"); result.TestString[2].Should().Be("3.14"); }
public void Map_ObjectWithIListProperty() { var target = RunnerFactory.Create(); var result = target.Query(new Map_StringList <TestObjectStringIList>()); result.TestString.Count.Should().Be(3); result.TestString[0].Should().Be("5"); result.TestString[1].Should().Be("TEST"); result.TestString[2].Should().Be("3.14"); }
public void Map_IEnumerable() { var target = RunnerFactory.Create(); var result = target.Query <IEnumerable>("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;").First(); var list = result.Cast <object>().ToList(); list.Count.Should().Be(3); list[0].Should().Be(5); list[1].Should().Be("TEST"); list[2].Should().Be(true); }
public void Map_Tuple_object() { var target = RunnerFactory.Create(); var result = target.Query <Tuple <int, object> >("SELECT 5 AS Id, 'TEST1' AS A, 'TEST2' AS B").First(); result.Item1.Should().Be(5); var item2 = result.Item2 as Dictionary <string, object>; item2["a"].Should().Be("TEST1"); item2["b"].Should().Be("TEST2"); }
public void AsEnumerableNextSeveral_Test() { var target = RunnerFactory.Create(); using (var stream = target.QueryStream(Query)) { var results = stream.AsEnumerableNextSeveral <int>(3).ToList(); results.Count.Should().Be(4); results.Should().ContainInOrder(1, 2, 3, 4); } }
public void Map_Tuple_CustomObject2() { var target = RunnerFactory.Create(); var result = target.Query <Tuple <TestObject1, int, TestObject1> >("SELECT 5 AS Id, 'TEST1' AS A, 'TEST2' AS B, 'TEST3' AS A, 'TEST4' AS B").First(); result.Item1.A.Should().Be("TEST1"); result.Item1.B.Should().Be("TEST2"); result.Item2.Should().Be(5); result.Item3.A.Should().Be("TEST3"); result.Item3.B.Should().Be("TEST4"); }
public void Map_IReadOnlyListT() { var target = RunnerFactory.Create(); var result = target.Query <IReadOnlyList <int> >("SELECT 5 AS A, 6 AS B, 7 AS C;").First(); var resultAsList = result.ToList(); resultAsList.Count.Should().Be(3); resultAsList[0].Should().Be(5); resultAsList[1].Should().Be(6); resultAsList[2].Should().Be(7); }
public void TestQuery_MapToObjectArray() { var target = RunnerFactory.Create(); var result = target.Query <object[]>("SELECT 5 AS TestInt, 'TEST' AS TestString, CAST(1 AS BIT) AS TestBool;").First(); result.Should().BeOfType <object[]>(); result.Length.Should().Be(3); result[0].Should().Be(5); result[1].Should().Be("TEST"); result[2].Should().Be(true); }
public void Primitive_string_Guid() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery <Guid>("SELECT '12345678-1234-1234-1234-123456789012' AS TestId;")); result.Should().NotBe(Guid.Empty); var result2 = target.Query(new TestQuery <Guid?>("SELECT '12345678-1234-1234-1234-123456789012' AS TestId;")); result2.Should().NotBeNull(); result2.Should().NotBe(Guid.Empty); }
public void Map_dynamic() { var target = RunnerFactory.Create(); dynamic result = target.Query <ExpandoObject>("SELECT 5 AS TestInt, 'TEST' AS TestString;").First(); string testString = result.teststring; testString.Should().Be("TEST"); int testInt = (int)result.testint; testInt.Should().Be(5); }
public void Map_IReadOnlyDictionaryOfObjectWithDuplicates() { var target = RunnerFactory.Create(); var dict = target.Query <IReadOnlyDictionary <string, object> >("SELECT 5 AS TestInt, 'A' AS TestString, 'B' AS TestString;").First(); dict.Count.Should().Be(2); dict["testint"].Should().Be(5); dict["teststring"].Should().BeOfType <object[]>(); var array = dict["teststring"] as object[]; array[0].Should().Be("A"); array[1].Should().Be("B"); }
public void TestQuery_ObjectPropertyMultipleValues() { var target = RunnerFactory.Create(); var result = target.Query <TestObject_WithChildObject>("SELECT 6 AS Id, 'A' AS Value, 'B' AS Value, 'C' AS value").First(); result.Id.Should().Be(6); result.Value.Should().BeOfType <object[]>(); var objArray = result.Value as object[]; objArray[0].Should().Be("A"); objArray[1].Should().Be("B"); objArray[2].Should().Be("C"); }