Example #1
0
        public void TestFindBy()
        {
            var userDataGateway    = new UserDataGateway(new UserContext(UserDbContextOptions));
            var accountDataGateway = new AccountDataGateway(new AccountContext(AccountDbContextOptions));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var info = service.CreateUserWithAccount("aUser");

            Assert.Equal("aUser", info.Name);
        }
        public void TestFindBy()
        {
            var userDataGateway    = new UserDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var accountDataGateway = new AccountDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var info = service.CreateUserWithAccount("aUser");

            Assert.Equal("aUser", info.Name);
        }
Example #3
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"]);
        }
Example #4
0
        public void TestPost()
        {
            _testScenarioSupport.LoadTestScenario("jacks-test-scenario");

            var userDataGateway    = new UserDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var accountDataGateway = new AccountDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var controller = new RegisationController(service);
            var value      = controller.Post(new UserInfo(-1, "aUser", ""));
            var actual     = (UserInfo)((ObjectResult)value).Value;

            Assert.True(actual.Id > 0);
            Assert.Equal("aUser", actual.Name);
            Assert.Equal("registration info", actual.Info);
        }
        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);
        }
Example #6
0
        public void TestFindBy()
        {
            Support.ExecSql(@"
insert into users (id, name) values (12, 'Jack');
insert into accounts (id, owner_id, name) values (1, 12, 'anAccount'), (2, 12, 'anotherAccount');
");

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

            var actual = gateway.FindBy(12);

            Assert.Equal(1, actual[0].Id);
            Assert.Equal(12, actual[0].OwnerId);
            Assert.Equal("anAccount", actual[0].Name);
            Assert.Equal(2, actual[1].Id);
            Assert.Equal(12, actual[1].OwnerId);
            Assert.Equal("anotherAccount", actual[1].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());
        }
Example #8
0
 public AccountService()
 {
     accountDataGateway = new ();
 }