Exemplo n.º 1
0
        /*
         * Methods addorned with the ConsoleAction attribute can be run
         * interactively from the command line while methods addorned with
         * the TestMethod attribute will be run automatically when the
         * compiled executable is run.  To run ConsoleAction methods use
         * the command line argument /i.
         *
         * All methods addorned with ConsoleAction and TestMethod attributes
         * must be static for the purposes of extending CommandLineTestInterface
         * or an exception will be thrown.
         *
         */


        // To run ConsoleAction methods use the command line argument /i.


        public static DaoCollection <TableColumns, TestDao> CreateTestDaoCollection()
        {
            DataTable table = new DataTable();

            table.Columns.Add("Name");
            for (int i = 0; i < 25; i++)
            {
                DataRow row = table.NewRow();
                row["Name"] = i.ToString();
                table.Rows.Add(row);
            }
            DaoCollection <TableColumns, TestDao> collection = new DaoCollection <TableColumns, TestDao>(table);

            return(collection);
        }
Exemplo n.º 2
0
        public static void DaoCollectionShouldBeEnumarable()
        {
            DaoCollection <TableColumns, TestDao> collection = TestProgram.CreateTestDaoCollection();

            Expect.AreEqual(3, collection.PageCount);
            int count = 0;

            foreach (TestDao dao in collection)
            {
                Expect.IsNotNullOrEmpty(dao.GetCurrentValue("Name").ToString());
                count++;
            }

            Expect.AreEqual(25, count);

            //foreach(List<TestDao> page in collection[
        }
Exemplo n.º 3
0
        public static void ShouldBeAbleToQueryById()
        {
            SqlClientRegistrar.Register(Db.For <DaoReferenceObject>().ServiceProvider);

            DaoReferenceObject test = new DaoReferenceObject();

            string val = "".RandomString(8);

            test.StringProperty = val;
            test.Commit();

            DaoCollection <DaoReferenceObjectColumns, DaoReferenceObject> results = new DaoCollection <DaoReferenceObjectColumns, DaoReferenceObject>(
                Select <DaoReferenceObjectColumns>
                .From <DaoReferenceObject>()
                .Where((c) => c.Id == test.Id)
                );

            Expect.IsNotNull(results);
            Expect.IsTrue(results.Count == 1);
            Expect.AreEqual(results[0].StringProperty, val);
        }