Beispiel #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"]);
        }
Beispiel #2
0
        public void TestCreate()
        {
            Support.ExecSql(@"
            insert into users (id, name) values (12, 'Jack');
            insert into accounts (id, owner_id, name) values (1, 12, 'anAccount');");

            var gateway = new ProjectDataGateway(new ProjectContext(DbContextOptions));

            gateway.Create(1, "aProject");

            // todo...
            var projects = Support.QuerySql("select name from projects where account_id = 1");

            Assert.Equal("aProject", projects[0]["name"]);
        }
        public void TestFindBy()
        {
            Support.ExecSql(
                @"insert into users (id, name) values (42346, 'aName'), (42347, 'anotherName'), (42348, 'andAnotherName');");

            var gateway = new UserDataGateway(new UserContext(DbContextOptions));

            var actual = gateway.FindObjectBy(42347);

            Assert.Equal(42347, actual.Id);
            Assert.Equal("anotherName", actual.Name);

            Assert.Null(gateway.FindObjectBy(42));
        }
        public void TestFind()
        {
            Support.ExecSql("insert into stories (id, project_id, name) values (1346, 22, 'aStory');");

            var gateway = new StoryDataGateway(new StoryContext(DbContextOptions));
            var list    = gateway.FindBy(22);

            // todo...
            var actual = list.First();

            Assert.Equal(1346, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal("aStory", actual.Name);
        }
Beispiel #5
0
        public void TestFind()
        {
            Support.ExecSql(@"insert into time_entries (id, project_id, user_id, date, hours) 
            values (2346, 22, 12, now(), 8);");

            var gateway = new TimeEntryDataGateway(new TimeEntryContext(DbContextOptions));
            var list    = gateway.FindBy(12);

            // todo...
            var actual = list.First();

            Assert.Equal(2346, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal(12, actual.UserId);
        }
Beispiel #6
0
        public void TestFind()
        {
            Support.ExecSql(@"insert into allocations 
            (id, project_id, user_id, first_day, last_day) values (97336, 22, 12, now(), now());");

            var gateway = new AllocationDataGateway(new AllocationContext(DbContextOptions));
            var list    = gateway.FindBy(22);

            // todo...
            var actual = list.First();

            Assert.Equal(97336, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal(12, actual.UserId);
        }
Beispiel #7
0
        public void TestFindBy()
        {
            var support = new TestDatabaseSupport(_dataSourceConfig);

            support.ExecSql(
                @"insert into users (id, name) values (42346, 'aName'), (42347, 'anotherName'), (42348, 'andAnotherName');");

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

            var actual = gateway.FindObjectBy(42347);

            Assert.Equal(42347, actual.Id);
            Assert.Equal("anotherName", actual.Name);

            Assert.Null(gateway.FindObjectBy(42));
        }
        public void TestFindBy()
        {
            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');
");

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

            var actual = gateway.FindBy(12);

            Assert.Equal(1, actual.Id);
            Assert.Equal(12, actual.OwnerId);
            Assert.Equal("anAccount", actual.Name);
        }
        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());
        }
Beispiel #10
0
        public void TestFindObject()
        {
            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, active) values (22, 1, 'aProject', true);
");

            var gateway = new ProjectDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var actual  = gateway.FindObject(22);

            // todo...
            Assert.Equal(22, actual.Id);
            Assert.Equal(1, actual.AccountId);
            Assert.Equal("aProject", actual.Name);
            Assert.Equal(true, actual.Active);
        }
Beispiel #11
0
        public void TestFind()
        {
            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');
insert into allocations (id, project_id, user_id, first_day, last_day) values (97336, 22, 12, now(), now());
");

            var gateway = new AllocationDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var list    = gateway.FindBy(22);

            // todo...
            var actual = list.First();

            Assert.Equal(97336, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal(12, actual.UserId);
        }
Beispiel #12
0
        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 AllocationDataGateway(new DatabaseTemplate(_dataSourceConfig));

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

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

            Assert.Equal(22, projectIds.First());
        }
        public void TestFind()
        {
            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');
insert into stories (id, project_id, name) values (1346, 22, 'aStory');
");

            var gateway = new StoryDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var list    = gateway.FindBy(22);

            // todo...
            var actual = list.First();

            Assert.Equal(1346, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal("aStory", actual.Name);
        }
        public void TestFind()
        {
            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');
insert into time_entries (id, project_id, user_id, date, hours) values (2346, 22, 12, now(), 8);
");

            var gateway = new TimeEntryDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var list    = gateway.FindBy(12);

            // todo...
            var actual = list.First();

            Assert.Equal(2346, actual.Id);
            Assert.Equal(22, actual.ProjectId);
            Assert.Equal(12, actual.UserId);
        }
Beispiel #15
0
        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');
");

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

            gateway.Create(1, "aProject");

            // todo...
            var template = new DatabaseTemplate(_dataSourceConfig);
            var projects = template.Query("select name from projects where account_id = 1",
                                          reader => reader.GetString(0),
                                          new List <DbParameter>());

            Assert.Equal("aProject", projects.First());
        }