Exemplo n.º 1
0
 private void IncompatibleScalarDestinationException()
 {
     // The return type 'System.Int32' of the method 'SelectAll'
     // is incompatible with the destination parameter type 'System.String'
     //
     DataAccessor.CreateInstance(typeof(IncompatibleScalarDestinationAccessor));
 }
Exemplo n.º 2
0
        public void Test1()
        {
            var da   = DataAccessor.CreateInstance <PersonAccessor>();
            var list = da.SelectByLastName("Pupkin");

            Assert.AreNotEqual(0, list.Count);
        }
Exemplo n.º 3
0
        public void Test4()
        {
            var da   = DataAccessor.CreateInstance <PersonAccessor>();
            var list = da.SelectID(42);

            Assert.AreEqual(42, list[0].ID);
        }
Exemplo n.º 4
0
        public void Test2()
        {
            var da   = (PersonAccessor)DataAccessor.CreateInstance(typeof(PersonAccessor));
            var list = da.SelectBy("FirstName", "John");

            Assert.AreNotEqual(0, list.Count);
        }
Exemplo n.º 5
0
        public void Test3()
        {
            var da   = (PersonAccessor)DataAccessor.CreateInstance(typeof(PersonAccessor));
            var list = da.SelectByLastName("Pupkin", 1);

            Assert.AreNotEqual(0, list.Count);
        }
Exemplo n.º 6
0
        public void ScalarDictionaryByPKTest()
        {
            TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            // Exception here:
            // Index is not defined for the method 'TestAccessor.ScalarDictionaryByPK'
            da.ScalarDictionaryByPK();
        }
Exemplo n.º 7
0
        public void KeylessTest()
        {
            TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            // Exception here:
            // Index is not defined for the method 'TestAccessor.Keyless'
            da.Keyless();
        }
Exemplo n.º 8
0
        public void QueryTest()
        {
            int[] intArray            = new int[] { 1, 2, 3, 4, 5 };
            int[] inputOutputIntArray = new int[5];

            ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor))).Query(
                intArray, ref inputOutputIntArray);

            Assert.AreEqual(intArray, inputOutputIntArray);
        }
Exemplo n.º 9
0
        public DataTypeTest()
        {
            TypeFactory.SaveTypes = true;

            object o = TypeAccessor.CreateInstance(typeof(ScalarData));

            Assert.IsInstanceOfType(typeof(ScalarData), o);

            _da = (DataTypeAccessor)DataAccessor.CreateInstance(typeof(DataTypeAccessor));
            Assert.IsInstanceOfType(typeof(DataTypeAccessor), _da);
        }
Exemplo n.º 10
0
        public void RefTest()
        {
            TestAccessor ta = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            RefEnum a;
            RefEnum b = RefEnum.E_B;

            ta.OutRefEnumTest("B", out a, ref b);

            Assert.AreEqual(RefEnum.E_B, a);
            Assert.AreEqual(RefEnum.E_BB, b);
        }
Exemplo n.º 11
0
        public void GenericsScalarDictionaryByPKWithObjectTypeTest()
        {
            TestAccessor             da      = DataAccessor.CreateInstance <TestAccessor>();
            Dictionary <int, object> persons = da.GenericsScalarDictionaryByPKWithObjectType();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);

            Person actualValue = (Person)persons[1];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 12
0
        public void GenericsDictionaryMismatchKeyTypeWithHierarchyTest()
        {
            TestAccessor da = DataAccessor.CreateInstance <TestAccessor>();
            Dictionary <long, Derived> persons = da.SelectAllDerived();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);

            Person actualValue = persons[1];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 13
0
        public void GenericsDictionaryMismatchKeyTypeCompoundValueTest()
        {
            TestAccessor da = DataAccessor.CreateInstance <TestAccessor>();
            Dictionary <CompoundValue, PersonMultiPK> persons = da.SelectAllT9();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);

            PersonMultiPK actualValue = persons[new CompoundValue(1, "Pupkin")];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 14
0
        public void Test()
        {
            TestAccessor ta = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));
            TestObject   o  = ta.LoadById(2);

            Assert.IsNotNull(o);
            Assert.IsNotNull(o.Xml);

            List <TestObject> lst = ta.LoadAll();

            Assert.IsNotEmpty(lst);
            Assert.IsNotNull(lst[0].Xml);
        }
Exemplo n.º 15
0
        public void GenericsScalarDictionaryByMapIndexTest()
        {
            TestAccessor da = DataAccessor.CreateInstance <TestAccessor>();
            Dictionary <CompoundValue, string> persons = da.GenericsScalarDictionaryByMapIndex();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);

            string actualValue = persons[new CompoundValue(_id, "John")];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue);
        }
Exemplo n.º 16
0
        public void Test()
        {
            TestAccessor ta = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            int id = ta.Person_Insert("Crazy", null, "Frog", Gender.E_Unknown);

#if ACCESS || SQLITE || SQLCE
            Assert.AreEqual(0, id);
            id = ta.Person_SelectByName("Crazy", "Frog");
#endif

            Assert.IsTrue(id > 0);
            ta.Person_Delete(id);
        }
Exemplo n.º 17
0
        public void GenericsScalarDictionaryByPKTest2()
        {
            TestAccessor da = DataAccessor.CreateInstance <TestAccessor>();

            Dictionary <int, string> persons = da.GenericsScalarDictionaryByPK2();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);

            string actualValue = persons[1];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue);
        }
Exemplo n.º 18
0
        public void DictionaryByIndexTest()
        {
            TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            Hashtable persons = da.DictionaryByIndex();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);
            Assert.IsNull(persons[-1]);

            Person actualValue = (Person)persons[_id];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 19
0
        public void DictionaryByMapIndexTestWithDestination()
        {
            TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            IDictionary persons = da.DictionaryByMapIndexWithDestination(new Hashtable());

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);
            Assert.IsNull(persons[-1]);

            Person actualValue = (Person)persons[new CompoundValue(1, "Pupkin")];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 20
0
        public void MultiPKTest()
        {
            TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));

            Hashtable persons = da.MultiPK();

            Assert.IsNotNull(persons);
            Assert.IsTrue(persons.Count > 0);
            Assert.IsNull(persons[new CompoundValue(-1, "NoSuchPerson")]);

            PersonMultiPK actualValue = (PersonMultiPK)persons[new CompoundValue(1, "Pupkin")];

            Assert.IsNotNull(actualValue);
            Assert.AreEqual("John", actualValue.FirstName);
        }
Exemplo n.º 21
0
        public void TestNullable1()
        {
            int?   @outputID;
            int?   @inputOutputID = 10;
            string @outputStr;
            string @inputOutputStr = "";

            DataAccessor.CreateInstance <TestNullableAccessor>()
            .OutRefTest(null, out @outputID, ref @inputOutputID,
                        null, out @outputStr, ref @inputOutputStr);

            Assert.IsNull(@outputID);
            Assert.IsNull(@inputOutputID);
            Assert.IsEmpty(@outputStr);
            Assert.IsEmpty(@inputOutputStr);
        }
Exemplo n.º 22
0
        public void Test1()
        {
            int    @outputID;
            int    @inputOutputID = 10;
            string @outputStr;
            string @inputOutputStr = "10";

            ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)))
            .OutRefTest(5, out @outputID, ref @inputOutputID,
                        "5", out @outputStr, ref @inputOutputStr);

            Assert.AreEqual(5, @outputID);
            Assert.AreEqual(15, @inputOutputID);
            Assert.AreEqual("5", @outputStr);
            Assert.AreEqual("510", @inputOutputStr);
        }
Exemplo n.º 23
0
        public void Test2()
        {
            Entity e = new Entity();
            int    @outputID;
            string @inputOutputStr = "20";

            ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)))
            .OutRefTest(out @outputID, e, ref @inputOutputStr);

            Assert.AreEqual(5, e.outputID);
            Assert.AreEqual(5, @outputID);
            Assert.AreEqual(15, e.inputOutputID);
            Assert.AreEqual("5", e.outputStr);
            Assert.AreEqual("510", e.inputOutputStr);
            Assert.AreEqual("510", @inputOutputStr);
        }
Exemplo n.º 24
0
        public void NullableTest()
        {
            int?[]   @outputIntArray;
            int?[]   @inputOutputIntArray = new int?[]   { 1, 2, 3, 4, 5 };
            string[] @outputStrArray;
            string[] @inputOutputStrArray = new string[] { "9", "8", "7", "6", "5" };

            ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor))).ArrayTest(
                new int?[]    { 1, null, 3, 4, 5 }, out @outputIntArray, ref @inputOutputIntArray,
                new string[] { "5", "4", "3", "2", "1" }, out @outputStrArray, ref @inputOutputStrArray);

            Assert.AreEqual(new int?[] { 1, 0, 3, 4, 5 }, @outputIntArray);
            Assert.AreEqual(new int?[] { 2, 0, 6, 8, 10 }, @inputOutputIntArray);
            Assert.AreEqual(new string[] { "5", "4", "3", "2", "1" }, @outputStrArray);
            Assert.AreEqual(new string[] { "95", "84", "73", "62", "51" }, @inputOutputStrArray);
        }
Exemplo n.º 25
0
        public void NullValueTest()
        {
            int    @outputID;
            int    @inputOutputID = 10;
            string @outputStr;
            string @inputOutputStr = "C";

            ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)))
            .OutRefTest2(-1, out @outputID, ref @inputOutputID,
                         "A", out @outputStr, ref @inputOutputStr);

            Assert.AreEqual(-2, @outputID);
            Assert.AreEqual(-3, @inputOutputID);
            Assert.AreEqual("B", @outputStr);
            Assert.AreEqual("C", @inputOutputStr);
        }
Exemplo n.º 26
0
        public void TestNullable2()
        {
            NullableEntity e = new NullableEntity();
            int?           @outputID;
            string         @inputOutputStr = "20";

            e.str = "20";

            DataAccessor.CreateInstance <TestNullableAccessor>()
            .OutRefTest(out @outputID, e, ref @inputOutputStr);

            Assert.IsNull(@outputID);
            Assert.AreEqual("20", e.outputStr);
            Assert.IsNull(e.inputOutputID);
            Assert.AreEqual("2040", @inputOutputStr);
        }
Exemplo n.º 27
0
        public void NullableScalarTest()
        {
            int?[] @outputIntArray = ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor))).NullableScalarArray();

            Assert.AreEqual(new int?[] { 1, 2, 3, 4, 5 }, @outputIntArray);
        }
Exemplo n.º 28
0
 private void MultiDestinationException()
 {
     // More then one parameter is marked as destination.
     //
     DataAccessor.CreateInstance(typeof(MultiDestinationAccessor));
 }
Exemplo n.º 29
0
 private void Typeless2()
 {
     // Can not determine object type for the method 'TypelessAccessor2.Typeless'
     //
     DataAccessor.CreateInstance(typeof(TypelessAccessor2));
 }
Exemplo n.º 30
0
 private void IllegalDataSetTable()
 {
     // DataSetTable attribute may not be an index
     //
     DataAccessor.CreateInstance(typeof(IllegalDataSetTableAccessor));
 }