コード例 #1
0
        public void TestCreate()
        {
            Support.ExecSql("insert into users (id, name) values (12, 'Jack');");

            var gateway = new AccountDataGateway(new AccountContext(DbContextOptions));

            gateway.Create(12, "anAccount");

            var names = Support.QuerySql("select name from accounts");

            Assert.Equal("anAccount", names[0]["name"]);
        }
コード例 #2
0
        public void TestCreate()
        {
            var support = new TestDatabaseSupport(_dataSourceConfig);

            support.ExecSql(@"
insert into users (id, name) values (12, 'Jack');
");

            var template = new DatabaseTemplate(_dataSourceConfig);
            var gateway  = new AccountDataGateway(template);

            gateway.Create(12, "anAccount");

            var names = template.Query("select name from accounts", reader => reader.GetString(0),
                                       new List <DbParameter>());

            Assert.Equal("anAccount", names.First());
        }