Exemple #1
0
        public void TestCreate()
        {
            var gateway = new TimeEntryDataGateway(new TimeEntryContext(DbContextOptions));

            gateway.Create(22, 12, DateTime.Now, 8);

            // todo...
            var projectIds = Support.QuerySql("select project_id from time_entries");

            Assert.Equal(22L, projectIds[0]["project_id"]);
        }
        public void TestCreate()
        {
            var support = new TestDatabaseSupport(_dataSourceConfig);

            support.ExecSql(@"
insert into users (id, name) values (12, 'Jack');
insert into accounts (id, owner_id, name) values (1, 12, 'anAccount');
insert into projects (id, account_id, name) values (22, 1, 'aProject');
");

            var gateway = new TimeEntryDataGateway(new DatabaseTemplate(_dataSourceConfig));

            gateway.Create(22, 12, DateTime.Now, 8);

            // todo...
            var template   = new DatabaseTemplate(_dataSourceConfig);
            var projectIds = template.Query("select project_id from time_entries", reader => reader.GetInt64(0),
                                            new List <DbParameter>());

            Assert.Equal(22, projectIds.First());
        }